12 #ifndef ROC_CORE_SLAB_POOL_H_
13 #define ROC_CORE_SLAB_POOL_H_
38 SlabPool_DefaultGuards =
71 template <
class T,
size_t EmbeddedCapacity = 0>
86 size_t min_alloc_bytes = 0,
87 size_t max_alloc_bytes = 0,
88 size_t guards = SlabPool_DefaultGuards)
94 embedded_data_.memory(),
95 embedded_data_.size(),
111 return impl_.
reserve(n_objects);
135 AlignedStorage<EmbeddedCapacity * SlotSize> embedded_data_;
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Base class for non-copyable objects.
ROC_ATTR_NODISCARD bool reserve(size_t n_objects)
Reserve memory for given number of objects.
void deallocate(void *memory)
Return memory to pool.
size_t object_size() const
Get size of the object.
size_t num_guard_failures() const
Get number of guard failures.
void * allocate()
Allocate memory for an object.
size_t allocation_size() const
Get size of the allocation per object.
virtual size_t object_size() const
Get size of the object.
virtual void * allocate()
Allocate memory for an object.
size_t num_guard_failures() const
Get number of guard failures detected.
virtual ROC_ATTR_NODISCARD bool reserve(size_t n_objects)
Reserve memory for given number of objects.
virtual void deallocate(void *memory)
Return memory to pool.
SlabPool(const char *name, IArena &arena, size_t object_size=sizeof(T), size_t min_alloc_bytes=0, size_t max_alloc_bytes=0, size_t guards=SlabPool_DefaultGuards)
Initialize.
virtual size_t allocation_size() const
Get size of the allocation per object.
SlabPoolGuard
Memory pool guards.
@ SlabPool_LeakGuard
Panic if leaks detected in pool destructor.
@ SlabPool_OverflowGuard
Panic if detected buffer overflow when deallocating object.
@ SlabPool_OwnershipGuard
Panic if detected ownership mismatch when deallocating object.
Memory pool implementation class.
Commonly used types and functions.
Maximum aligned data unit.