![]() |
Public API Reference |
![]() |
Thread-safe allocator for objects of a class. More...
#include <csutil/blockallocator.h>
Public Member Functions | |
T * | Alloc () |
Allocate a new object. | |
template<typename A1 , typename A2 > | |
T * | Alloc (A1 &a1, A2 &a2) |
Allocate a new object. | |
template<typename A1 , typename A2 , typename A3 > | |
T * | Alloc (A1 &a1, A2 &a2, A3 &a3) |
Allocate a new object. | |
template<typename A1 > | |
T * | Alloc (A1 &a1) |
Allocate a new object. | |
void | Compact () |
Compact the allocator so that all blocks that are completely unused are removed. | |
void | DeleteAll () |
Destroy all objects allocated by the pool and release the memory. | |
void | Empty () |
Destroy all objects allocated by the pool without releasing the memory. | |
void | Free (T *p) |
Deallocate an object. | |
bool | TryFree (T *p) |
Try to delete an object. |
Thread-safe allocator for objects of a class.
Has the same purpose and interface as csBlockAllocator but is safe to be used concurrently from different threads.
Definition at line 295 of file blockallocator.h.
T* CS::Memory::BlockAllocatorSafe< T, Allocator, ObjectDispose, SizeComputer >::Alloc | ( | ) | [inline] |
Allocate a new object.
The default (no-argument) constructor of T is invoked.
Reimplemented from csBlockAllocator< T, Allocator, ObjectDispose, SizeComputer >.
Definition at line 326 of file blockallocator.h.
T* CS::Memory::BlockAllocatorSafe< T, Allocator, ObjectDispose, SizeComputer >::Alloc | ( | A1 & | a1, |
A2 & | a2 | ||
) | [inline] |
Allocate a new object.
The two-argument constructor of T is invoked.
Reimplemented from csBlockAllocator< T, Allocator, ObjectDispose, SizeComputer >.
Definition at line 333 of file blockallocator.h.
T* CS::Memory::BlockAllocatorSafe< T, Allocator, ObjectDispose, SizeComputer >::Alloc | ( | A1 & | a1, |
A2 & | a2, | ||
A3 & | a3 | ||
) | [inline] |
Allocate a new object.
The three-argument constructor of T is invoked.
Reimplemented from csBlockAllocator< T, Allocator, ObjectDispose, SizeComputer >.
Definition at line 340 of file blockallocator.h.
T* CS::Memory::BlockAllocatorSafe< T, Allocator, ObjectDispose, SizeComputer >::Alloc | ( | A1 & | a1 | ) | [inline] |
Allocate a new object.
The one-argument constructor of T is invoked.
Reimplemented from csBlockAllocator< T, Allocator, ObjectDispose, SizeComputer >.
Definition at line 347 of file blockallocator.h.
void CS::Memory::BlockAllocatorSafe< T, Allocator, ObjectDispose, SizeComputer >::Compact | ( | ) | [inline] |
Compact the allocator so that all blocks that are completely unused are removed.
The blocks that still contain elements are not touched.
Reimplemented from csFixedSizeAllocator< SizeComputer::value, Allocator >.
Definition at line 320 of file blockallocator.h.
void CS::Memory::BlockAllocatorSafe< T, Allocator, ObjectDispose, SizeComputer >::DeleteAll | ( | ) | [inline] |
Destroy all objects allocated by the pool and release the memory.
Reimplemented from csBlockAllocator< T, Allocator, ObjectDispose, SizeComputer >.
Definition at line 314 of file blockallocator.h.
void CS::Memory::BlockAllocatorSafe< T, Allocator, ObjectDispose, SizeComputer >::Empty | ( | ) | [inline] |
Destroy all objects allocated by the pool without releasing the memory.
Reimplemented from csBlockAllocator< T, Allocator, ObjectDispose, SizeComputer >.
Definition at line 308 of file blockallocator.h.
void CS::Memory::BlockAllocatorSafe< T, Allocator, ObjectDispose, SizeComputer >::Free | ( | T * | p | ) | [inline] |
Deallocate an object.
It is safe to provide a null pointer.
p | Pointer to deallocate. |
Reimplemented from csBlockAllocator< T, Allocator, ObjectDispose, SizeComputer >.
Definition at line 353 of file blockallocator.h.
bool CS::Memory::BlockAllocatorSafe< T, Allocator, ObjectDispose, SizeComputer >::TryFree | ( | T * | p | ) | [inline] |
Try to delete an object.
Usage is the same as Free(), the difference being that false
is returned if the deallocation failed (the reason is most likely that the memory was not allocated by the allocator).
Reimplemented from csBlockAllocator< T, Allocator, ObjectDispose, SizeComputer >.
Definition at line 358 of file blockallocator.h.