Lumiera
0.pre.03
»edit your freedom«
|
"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.
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 Monitor & | getMonitor (Sync const *forThis) |
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().