58#ifndef LIB_TYPED_ALLOCATION_MANAGER_H
59#define LIB_TYPED_ALLOCATION_MANAGER_H
73 using std::shared_ptr;
147 return shared_ptr<XOX> (toTrack,
getDeleter());
170 template<
class XX,
typename...ARGS>
176 return slot.build (
new(slot.storage_) XX (std::forward<ARGS> (args)...) );
180 releaseSlot<XX>(slot.storage_);
197 TRACE (memory,
"allocate «%s»", util::typeStr<XX>().c_str());
198 void* space =
new char[
sizeof(XX)];
208 TRACE (memory,
"release «%s»", util::typeStr<XX>().c_str());
209 typedef char Storage[
sizeof(XX)];
210 delete[]
reinterpret_cast<Storage*
> (entry);
228 WARN (command_dbg,
"dtor of «%s» failed: %s", util::typeStr(entry).c_str()
231 releaseSlot<XX> (entry);
opaque link to the manager, to be used by handles and smart-ptrs to trigger preconfigured destruction...
void operator()(XOX *victim)
Foundation for a custom allocation manager, tracking the created objects by smart-ptrs.
void destroyElement(XX *entry)
shared_ptr< XX > create(ARGS &&...args)
void releaseSlot(void *entry)
Slot< XX > allocateSlot()
TypedAllocationManager _TheManager
lib::TypedCounter allocCnt_
Utility providing a set of counters, each tied to a specific type.
lumiera_err lumiera_error(void)
Get and clear current error state.
Lumiera error handling (C++ interface).
This header is for including and configuring NoBug.
Implementation namespace for support and library code.
a token representing a newly opened slot capable for holding an object of type XOX .
void *const storage_
pointer to the allocated storage with sizeof(XOX) bytes
Slot(_TheManager *don, void *mem)
Killer< XOX > const & getDeleter()
shared_ptr< XOX > build(XOX *toTrack)
build a refcounting smart-ptr, complete with back-link to the manager for de-allocation
Creating series of type-based contexts.