Embedded Multicore Building Blocks V1.0.0
|
Pool for thread-safe management of arbitrary objects. More...
#include <object_pool.h>
Public Member Functions | |
ObjectPool (size_t capacity) | |
Constructs an object pool with capacity capacity . More... | |
~ObjectPool () | |
Destructs the pool. More... | |
size_t | GetCapacity () |
Returns the capacity of the pool. More... | |
void | Free (Type *obj) |
Returns an element to the pool. More... | |
Type * | Allocate (...) |
Allocates an element from the pool. More... | |
Pool for thread-safe management of arbitrary objects.
Type | Element type |
ValuePool | Type of the underlying value pool, determines whether the object pool is wait-free or lock-free |
ObjectAllocator | Type of allocator used to allocate objects |
embb::containers::ObjectPool< Type, ValuePool, ObjectAllocator >::ObjectPool | ( | size_t | capacity | ) |
Constructs an object pool with capacity capacity
.
capacity
elements of type Type
.[in] | capacity | Number of elements the pool can hold |
embb::containers::ObjectPool< Type, ValuePool, ObjectAllocator >::~ObjectPool | ( | ) |
Destructs the pool.
size_t embb::containers::ObjectPool< Type, ValuePool, ObjectAllocator >::GetCapacity | ( | ) |
Returns the capacity of the pool.
void embb::containers::ObjectPool< Type, ValuePool, ObjectAllocator >::Free | ( | Type * | obj | ) |
Returns an element to the pool.
If the underlying value pool is wait-free/lock-free, this operation is also wait-free/lock-free, respectively.
[in] | obj | Pointer to the object to be freed |
Type* embb::containers::ObjectPool< Type, ValuePool, ObjectAllocator >::Allocate | ( | ... | ) |
Allocates an element from the pool.
If the underlying value pool is wait-free/lock-free, this operation is also wait-free/lock-free, respectively.
NULL
.... | Arguments of arbitrary type, passed to the object's constructor |