43 Pool(
size_t granularity,
size_t size);
93 char const* block =
reinterpret_cast<char const*
>( instance );
Simple pool class.
Definition: stl_pool.h:40
void Destroy(T *instance)
Destructs an object back into the pool.
Definition: stl_pool.h:84
size_t volatile m_used
The number of pooled allocations.
Definition: stl_pool.h:99
T * Construct()
Constructs an object from the pool.
Definition: stl_pool.h:76
bool IsFromPool(void const *instance) const
Returns true if the given instance is from pooled storage.
Definition: stl_pool.h:92
size_t volatile m_overflow
The number of non-pooled allocations.
Definition: stl_pool.h:100
size_t m_size
The number of elements in pooled storage.
Definition: stl_pool.h:98
size_t GetOverflow() const
Gets the number of elements allocated from non-pooled storage.
Definition: stl_pool.h:64
array_guard_t< void * > m_slots
The free list.
Definition: stl_pool.h:103
size_t GetGranularity() const
Gets the pool granularity.
Definition: stl_pool.h:49
array_guard_t< char > m_storage
The pool storage.
Definition: stl_pool.h:102
~Pool()
Checks for emptiness before destructing.
Definition: stl_pool.cpp:51
size_t GetSize() const
Gets the pool size in elements.
Definition: stl_pool.h:54
Pool(size_t granularity, size_t size)
Allocates a pool with size elements each of granularity bytes.
Definition: stl_pool.cpp:36
void * Allocate()
Allocates memory from the pool without construction.
Definition: stl_pool.cpp:64
size_t GetUsed() const
Gets the number of elements allocated from pooled storage.
Definition: stl_pool.h:59
#define T
Definition: w_okvl_inl.h:45
void Deallocate(void *block)
Deallocates memory from the pool without destruction.
Definition: stl_pool.cpp:74
T get() const
Definition: guard.h:283
size_t m_granularity
The size of each element in the pool in bytes.
Definition: stl_pool.h:97