|
cppcore
A small, portable C++ core library
|
This class implements a simple pool-based allocation scheme. More...
#include <TPoolAllocator.h>
Public Member Functions | |
| TPoolAllocator ()=default | |
| The default class constructor. | |
| TPoolAllocator (size_t numItems) | |
| The class constructor with the pool size. | |
| ~TPoolAllocator () | |
| The class destructor. | |
| T * | alloc () |
| WIll alloc one item from the pool. | |
| void | release () |
| Will release all allocated items. | |
| void | reserve (size_t size) |
| Will reserve the pool. | |
| void | clear () |
| Will clear the pool, memory will be deallocated. | |
| size_t | capacity () const |
| Returns the capacity of items in the pool allocator. | |
| size_t | reservedMem () const |
| WIll return the reserved memory in bytes. | |
| size_t | freeMem () const |
| Will return the free memory in the pool in bytes. | |
| void | dumpAllocations (std::string &allocs) |
| Will dump a statistic overview into the given string. | |
| void | resize (size_t growSize) |
| Will perform a resize for the pool. | |
| void | reset () |
| Will reset the allocator. | |
This class implements a simple pool-based allocation scheme.
Initially you have to define its size. Each allocation will be done from this initially created pool. You have to release all pooled instances after the usage. This allocation scheme is fast and does no call any new-calls during the lifetime of the allocator.
Definition at line 49 of file TPoolAllocator.h.
|
default |
|
inline |
The class constructor with the pool size.
| numItems | [in] The pool size. |
Definition at line 139 of file TPoolAllocator.h.
|
inline |
|
inline |
WIll alloc one item from the pool.
Definition at line 151 of file TPoolAllocator.h.
References resize().
|
inline |
Returns the capacity of items in the pool allocator.
Definition at line 211 of file TPoolAllocator.h.
|
inline |
Will clear the pool, memory will be deallocated.
Definition at line 195 of file TPoolAllocator.h.
Referenced by reserve(), and ~TPoolAllocator().
|
inline |
Will dump a statistic overview into the given string.
| allocs | [inout] The string to hold the allocation statistic. |
Definition at line 230 of file TPoolAllocator.h.
|
inline |
Will return the free memory in the pool in bytes.
Definition at line 221 of file TPoolAllocator.h.
|
inline |
Will release all allocated items.
Definition at line 167 of file TPoolAllocator.h.
|
inline |
Will reserve the pool.
@apram size [in] The pool size to reserve.
Definition at line 182 of file TPoolAllocator.h.
References clear().
|
inline |
WIll return the reserved memory in bytes.
Definition at line 216 of file TPoolAllocator.h.
| void cppcore::TPoolAllocator< T >::reset | ( | ) |
Will reset the allocator.
Definition at line 261 of file TPoolAllocator.h.
|
inline |
Will perform a resize for the pool.
| growSize | [in] The soze to grow. |
Definition at line 238 of file TPoolAllocator.h.
Referenced by alloc().