Template Class ObjectPool
Defined in File ObjectPool.h
Nested Relationships
Nested Types
Class Documentation
-
template<class T, class A = HugePageAllocator<T>>
class ObjectPool a pool of objects of type T in blocks of at most n slots
Public Functions
-
explicit ObjectPool(std::size_t n = std::size_t(1) << 24, const A &alloc = A())
an empty pool whose blocks grow up to n slots
- Pre:
n >= 1
-
ObjectPool(const ObjectPool&) = delete
-
ObjectPool &operator=(const ObjectPool&) = delete
-
ObjectPool(ObjectPool &&other) noexcept
the slots of other, which is left empty; its objects stay where they are
-
ObjectPool &operator=(ObjectPool &&other) noexcept
-
~ObjectPool()
frees the blocks; the objects still alive are not destroyed
-
void swap(ObjectPool &other) noexcept
-
template<class ...Args>
T *make(Args&&... args) a new object built from the arguments, in the slot freed last if any
-
void free(T *x)
destroys x and keeps its slot for the next make()
- Pre:
x was made by this pool and is alive
-
T *allocate(void)
the raw slot of an object, not built, as std::allocator gives it: the caller builds the object in it (and destroys it before deallocate())
-
void deallocate(T *x)
keeps the slot of x, whose object is already destroyed (or was never built), for the next make() or allocate()
- Pre:
x was given by this pool
-
std::size_t size(void) const
the number of objects alive
-
std::size_t bytes(void) const
the memory of the blocks, in bytes
-
explicit ObjectPool(std::size_t n = std::size_t(1) << 24, const A &alloc = A())