FObjectPool allocates objects in blocks with MAX_USHORT elements per block. More...
#include <fmemory.h>
Public Member Functions | |
FObjectPool (uint16 elementSize) | |
Constructor. | |
~FObjectPool () | |
Destructor. Releases allocated memory back to the heap. | |
void * | newElement () |
allocate memory from within the preallocated memory block. If no more free entries are found, a new memory block is allocated. | |
void | deleteElement (void *el) |
return element to the pool. |
FObjectPool allocates objects in blocks with MAX_USHORT elements per block.
FObjectPool can be used, if a lot of small equal sized elements are needed. Allocation and deallocation are fast and have little memory overhead. FObjectPool should not be used for large objects.
Memory is not released to the heap until the destructor of FBlockAllocator.
FObjectPool is thread safe, as it uses FLock to synchronize modifications.
FObjectPool | ( | uint16 | elementSize | ) |
Constructor.
[in] | elementSize | : size of one element |
~FObjectPool | ( | ) |
Destructor. Releases allocated memory back to the heap.
void * newElement | ( | ) |
allocate memory from within the preallocated memory block. If no more free entries are found, a new memory block is allocated.
void deleteElement | ( | void * | el | ) |
return element to the pool.