69 :
public Sync<RecursiveLock_NoWait>
71 typedef std::deque<char*> MemTable;
87 void commit (
void* pendingAlloc);
107 AllocationCluster::MemoryManager::reset (
TypeInfo info)
111 if (0 < mem_.size()) purge();
115 ENSURE (isnil (mem_));
116 ENSURE (0 < type_.allocSize);
122 AllocationCluster::MemoryManager::purge()
126 REQUIRE (type_.
killIt,
"we need a deleter function");
127 REQUIRE (0 < type_.allocSize,
"allocation size unknown");
128 REQUIRE (
top_ == mem_.size() || (
top_+1) == mem_.size());
137 AllocationCluster::MemoryManager::clearStorage()
139 for (
size_t i=mem_.size(); 0 < i; )
146 AllocationCluster::MemoryManager::allocate()
150 REQUIRE (0 < type_.allocSize);
151 REQUIRE (
top_ <= mem_.size());
153 if (
top_==mem_.size())
157 mem_[
top_] =
new char[type_.allocSize];
159 ENSURE (top_ < mem_.size());
166 AllocationCluster::MemoryManager::commit (
void* pendingAlloc)
170 REQUIRE (pendingAlloc);
171 ASSERT (
top_ < mem_.size());
172 ASSERT (pendingAlloc == mem_[
top_],
"allocation protocol violated");
176 ENSURE (top_ == mem_.size());
191 TRACE (memory,
"new AllocationCluster");
205 TRACE (memory,
"shutting down AllocationCluster");
215 WARN (progress,
"Exception while closing AllocationCluster: %s", ex.
what());
217 TRACE (debugging,
"Error flag was: %s", errID);
221 ALERT (progress,
"Unexpected fatal Exception while closing AllocationCluster.");
222 lumiera::error::lumiera_unexpectedException();
234 return handler(slot)->allocate();
248 if (not handler(slot))
253 ASSERT (handler(slot));
261 ASSERT (handler(slot));
262 ASSERT (allocatedObj);
264 handler(slot)->commit(allocatedObj);
276 typedef ManagerTable::const_iterator Iter;
280 size += (*ii)->size();
290 return handler(slot)->size();
Facility for monitor object based locking.
static size_t maxTypeIDs
storage for static bookkeeping of type allocation slots
void finishAlloc(size_t &slot, void *)
enrol the allocation after successful ctor call
size_t size() const
the top_ index always points at the next slot not yet holding a finished, committed allocation...
size_t top_
index of the next slot available for allocation
Memory management for the low-level model (render nodes network).
void(* killIt)(void *)
deleter function
virtual CStr what() const noexcept override
std::exception interface : yield a diagnostic message
Implementation namespace for support and library code.
Object Monitor based synchronisation.
size_t countActiveInstances(size_t &slot) const
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
void * initiateAlloc(size_t &slot)
implementation of the actual memory allocation is pushed down to the MemoryManager impl...
lumiera_err lumiera_error(void)
Get and clear current error state.
ManagerTable typeHandlers_
table of active MemoryManager instances
Lumiera error handling (C++ interface).
A synchronisation protection guard employing a lock scoped to the parameter type as a whole...
"Low-level" Memory manager for allocating small objects of a fixed size.
Interface and Base definition for all Lumiera Exceptions.
~AllocationCluster() noexcept
On shutdown of the AllocationCluster we need to assure a certain destruction order is maintained by e...
AllocationCluster()
creating a new AllocationCluster prepares a table capable of holding the individual object families t...