12 #ifndef ROC_CORE_SLAB_POOL_IMPL_H_
13 #define ROC_CORE_SLAB_POOL_IMPL_H_
63 size_t min_alloc_bytes,
64 size_t max_alloc_bytes,
65 void* preallocated_data,
66 size_t preallocated_size,
91 void* give_slot_to_user_(Slot* slot);
92 Slot* take_slot_from_user_(
void* memory);
94 Slot* acquire_slot_();
95 void release_slot_(Slot* slot);
96 bool reserve_slots_(
size_t desired_slots);
98 void increase_slab_size_(
size_t desired_n_slots);
99 bool allocate_new_slab_();
100 void deallocate_everything_();
102 void add_preallocated_memory_(
void* memory,
size_t memory_size);
104 size_t slots_per_slab_(
size_t slab_size,
bool round_up)
const;
105 size_t slot_offset_(
size_t slot_index)
const;
112 List<Slab, NoOwnership> slabs_;
113 List<Slot, NoOwnership> free_slots_;
114 size_t n_used_slots_;
116 const size_t slab_min_bytes_;
117 const size_t slab_max_bytes_;
119 const size_t unaligned_slot_size_;
120 const size_t slot_size_;
121 const size_t slab_hdr_size_;
123 size_t slab_cur_slots_;
124 const size_t slab_max_slots_;
126 const size_t object_size_;
127 const size_t object_size_padding_;
130 size_t num_guard_failures_;
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Base class for list element.
Base class for non-copyable objects.
Memory pool implementation class.
ROC_ATTR_NODISCARD bool reserve(size_t n_objects)
Reserve memory for given number of objects.
void deallocate(void *memory)
Return memory to pool.
SlabPoolImpl(const char *name, IArena &arena, size_t object_size, size_t min_alloc_bytes, size_t max_alloc_bytes, void *preallocated_data, size_t preallocated_size, size_t flags)
Initialize.
size_t object_size() const
Get size of objects in pool.
size_t num_guard_failures() const
Get number of guard failures.
void * allocate()
Allocate memory for an object.
AlignMax SlotCanary
Canary guard which surrounds variable-length data.
~SlabPoolImpl()
Deinitialize.
Intrusive doubly-linked list.
Commonly used types and functions.
Maximum aligned data unit.