Memory pool for allocations of elements of a single fixed size. Memory is allocated from the OS in chunks, the pool grows in capacity as elements are allocated from it.
Pool::Pool | ( | size_t | elemsize, | |
size_t | block_size | |||
) | [inline] |
Allocates a pool with block_size
elements of elemsize
bytes each. The pool will grow in increments of block_size
. Memory is NOT returned to the OS.
void* Pool::Allocate | ( | ) | [inline] |
References AllocateNewBlock(), m_size, m_slots, and m_used.
Referenced by PooledList< T >::alloc(), PooledAllocator< T >::allocate(), and Construct().
void Pool::Deallocate | ( | void * | element | ) | [inline] |
References m_slots, and m_used.
Referenced by PooledList< T >::dealloc(), PooledAllocator< T >::deallocate(), and Destroy().
size_t Pool::GetElemSize | ( | ) | const [inline] |
References m_elemsize.
Referenced by PooledAllocator< T >::PooledAllocator().
size_t Pool::GetSize | ( | ) | const [inline] |
References m_size.
size_t Pool::GetUsed | ( | ) | const [inline] |
References m_used.
T* Pool::Construct | ( | ) | [inline] |
References Allocate().
void Pool::Destroy | ( | T * | instance | ) | [inline] |
References Deallocate().
void Pool::AllocateNewBlock | ( | void | ) | [inline, private] |
References m_blocksize, m_elemsize, m_size, m_slots, m_storage, and m_used.
Referenced by Allocate().
size_t Pool::m_elemsize [private] |
Referenced by AllocateNewBlock(), and GetElemSize().
size_t Pool::m_blocksize [private] |
Referenced by AllocateNewBlock().
size_t Pool::m_size [private] |
Referenced by Allocate(), AllocateNewBlock(), and GetSize().
size_t Pool::m_used [private] |
Referenced by Allocate(), AllocateNewBlock(), Deallocate(), GetUsed(), and ~Pool().
std::vector<char*> Pool::m_storage [private] |
Referenced by AllocateNewBlock(), and ~Pool().
std::vector<void*> Pool::m_slots [private] |
Referenced by Allocate(), AllocateNewBlock(), and Deallocate().