|
Foundation
|
Atomic, bounded object pool of fixed allocation sizes. Being a sibling to AtomicStack - key differences being how objects are allocated in a fixed-size arena and is never freed back to the system. Deallocation returns objects to the pool for reuse. That - and you get stable pointers to objects directly. More...
#include <AtomicPool.hpp>
Classes | |
| struct | Node |
| struct | PTag |
Public Member Functions | |
| AtomicPool ()=default | |
| AtomicPool (size_t size, Allocator *alloc) | |
| template<typename... Args> | |
| T * | Construct (Args &&... args) |
| Constructs an object of type T in the pool with the given arguments. | |
| void | Destruct (T *ptr) |
| Destructs the object pointed to by ptr and returns it to the pool. | |
| size_t | Index (T *ptr) const |
| Returns the index of the given pointer in the pool. | |
| T * | At (size_t index) |
| Returns the pointer at the given index in the pool. | |
| void | Collect () |
| Destruct all allocated objects in the pool, collecting garbage. | |
| ~AtomicPool () | |
Private Member Functions | |
| Node * | AllocateNode () |
| void | DeallocateNode (Node *node) |
Private Attributes | |
| Node * | mNodes {nullptr} |
| size_t | mSize {0} |
| Atomic< PTag > | mHead {} |
| ScopedArena | mArena |
Atomic, bounded object pool of fixed allocation sizes. Being a sibling to AtomicStack - key differences being how objects are allocated in a fixed-size arena and is never freed back to the system. Deallocation returns objects to the pool for reuse. That - and you get stable pointers to objects directly.
| T | Type of object to allocate, must be default constructible. |
|
default |
|
inline |
|
inline |
|
inlineprivate |
Returns the pointer at the given index in the pool.
|
inline |
Destruct all allocated objects in the pool, collecting garbage.
|
inline |
Constructs an object of type T in the pool with the given arguments.
delete to free the returned pointer as it is managed by the pool. The destructor of T should NOT be manually called - handle both with Deallocate.
|
inlineprivate |
Destructs the object pointed to by ptr and returns it to the pool.
Returns the index of the given pointer in the pool.
|
private |
|
private |