Lumiera  0.pre.03
»edit your freedom«
AllocationCluster::MemoryManager Class Reference

Description

"Low-level" Memory manager for allocating small objects of a fixed size.

The usage pattern is definite: Objects will be allocated in the course of a build process and then live until all Objects will be purged in one sway. Allocations will be requested one by one and immediately committed after successful ctor call of the object being allocated. Allocations and commits can be assumed to come in pairs, thus if an allocation immediately follows another one (without commit), the previous allocation can be considered a failure and can be dropped silently. After an allocation succeeds (i.e. was committed), the MemoryManager is in charge for the lifecycle of the object within the allocated space and has to guarantee calling it's dtor, either on shutdown or on explicit #purge() – the type info structure handed in on initialisation provides a means for invoking the dtor without actually knowing the object's type.

Todo:
this is a preliminary or pseudo-implementation based on a vector of raw pointers, i.e. actually the objects are heap allocated. What actually should happen is for the MemoryManager to allocate raw memory chunk wise, sub partition it and place the objects into this private memory buffer. Further, possibly we could maintain a pool of raw memory chunks used by all MemoryManager instances. I am skipping those details for now (10/2008) because they should be based on real-world measurements, not guessing.

Definition at line 68 of file allocation-cluster.cpp.

Public Member Functions

 MemoryManager (TypeInfo info)
 
void * allocate ()
 
void commit (void *pendingAlloc)
 
void purge ()
 
void reset (TypeInfo info)
 
size_t size () const
 the top_ index always points at the next slot not yet holding a finished, committed allocation. More...
 

Private Types

typedef std::deque< char * > MemTable
 

Private Member Functions

void clearStorage ()
 

Private Attributes

MemTable mem_
 
size_t top_
 index of the next slot available for allocation
 
TypeInfo type_
 

Additional Inherited Members

- Static Public Member Functions inherited from Sync< RecursiveLock_NoWait >
static MonitorgetMonitor (Sync const *forThis)
 

Member Function Documentation

◆ size()

size_t size ( ) const

the top_ index always points at the next slot not yet holding a finished, committed allocation.

Index is zero based, thus top_ == count of living objects

Definition at line 100 of file allocation-cluster.cpp.

References AllocationCluster::MemoryManager::top_.

Referenced by AllocationCluster::size().

+ Here is the caller graph for this function:
+ Inheritance diagram for AllocationCluster::MemoryManager:
+ Collaboration diagram for AllocationCluster::MemoryManager:

The documentation for this class was generated from the following file: