102 std::byte storage[max_size()];
106 static_assert (
sizeof(
Destructors) ==
sizeof(
void*));
107 static_assert (
sizeof(
Extents) ==
sizeof(
void*));
137 view_.extents.
clear();
143 getCurrentBlockStart()->dtors.push (dtor);
150 return nullptr == view_.storage.pos;
154 determineExtentCnt()
const 162 calcAllocInCurrentBlock()
const 164 ENSURE (max_size() >= view_.storage.rest);
165 return max_size() - view_.storage.rest;
171 getCurrentBlockStart()
const 173 REQUIRE (not empty());
174 void* pos =
static_cast<byte*
>(view_.storage.pos)
177 return static_cast<Extent*> (pos);
185 view_.storage.pos = getCurrentBlockStart();
186 view_.storage.rest = 0;
193 view_.storage.pos = & view_.extents.
top().storage;
194 view_.storage.rest = max_size();
210 TRACE (memory,
"new AllocationCluster");
223 TRACE (memory,
"shutting down AllocationCluster");
224 StorageManager::access(*this).discardAll();
243 ENSURE (allocRequest <=
max_size());
244 StorageManager::access(*this).addBlock();
249 AllocationCluster::registerDestructor (
Destructor& dtor)
251 StorageManager::access(*this).attach (dtor);
267 REQUIRE (isPow2 (align));
270 throw err::Fatal{
_Fmt{
"AllocationCluster: desired allocation of %d bytes " 271 "exceeds the fixed extent size of %d"} % allocSiz %
max_size()
275 throw err::Fatal{
_Fmt{
"AllocationCluster: data requires alignment at %d bytes, " 276 "which is beyond the fixed extent size of %d"} % align %
max_size()
285 AllocationCluster::numExtents()
const 287 return StorageManager::access (unConst(*
this)).determineExtentCnt();
298 size_t extents = numExtents();
299 if (not extents)
return 0;
300 size_t bytes = StorageManager::access (unConst(*
this)).calcAllocInCurrentBlock();
301 return (extents - 1) *
max_size() + bytes;
TY & emplace(ARGS &&...args)
prepend object of type TY, forwarding ctor args
void dispose(X *elm)
while this policy doesn't take ownership, it ensures the destructor is invoked
#define ERROR_LOG_AND_IGNORE(_FLAG_, _OP_DESCR_)
convenience shortcut for a sequence of catch blocks just logging and consuming an error...
An overlay view for the AllocationCluster to add functionality for adding / clearing extents and regi...
Memory management for the low-level model (render nodes network).
Any copy and copy construction prohibited.
Special allocator-policy for lib::LinkedElements.
A front-end for using printf-style formatting.
void expandStorage(size_t)
Expand the alloted storage pool by a block, suitable to accommodate at least the indicated request...
Implementation namespace for support and library code.
Block of allocated storage.
Derived specific exceptions within Lumiera's exception hierarchy.
void __enforce_limits(size_t, size_t)
Allocation cluster uses a comparatively small tile size for its extents, which turns out to be a freq...
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Utilities for quantisation (grid alignment) and comparisons.
Intrusive single linked list with optional ownership.
A pile of objects sharing common allocation and lifecycle.
auto & asLinkedElements(N *const &anchor)
transiently reinterpret an element pointer as const LinkedElements, allowing to count, iterate or subscript a chain of elements
maintaining the Allocation
static size_t constexpr max_size()
Maximum individual allocation size that can be handled.
~AllocationCluster() noexcept
The shutdown of an AllocationCluster walks all extents and invokes all registered deleter functions a...
AllocationCluster()
Prepare a new clustered allocation to be expanded by extents of size EXTENT_SIZ, yet discarded all at...
Policy for LinkedElements: never create or destroy any elements, only allow to add already existing n...