|
Open Model Railroad Network (OpenMRN)
|
Implementation of a Pool interface that takes memory from mainBufferPool (configurable) but limits the number of buffers allocatable. More...
#include <LimitedPool.hxx>
Public Member Functions | |
| LimitedPool (unsigned entry_size, unsigned entry_count, Pool *base_pool=nullptr) | |
| size_t | free_items () override |
| Number of free items in the pool. | |
| size_t | free_items (size_t size) override |
| Number of free items in the pool for a given allocation size. | |
Public Member Functions inherited from Pool | |
| size_t | total_size () |
| template<class BufferType > | |
| void | alloc (Buffer< BufferType > **result, Executable *flow=NULL) |
| Get a free item out of the pool. | |
| template<class BufferType > | |
| void | alloc (BufferPtr< BufferType > *result) |
| Get a free item out of the pool. | |
| template<class BufferType > | |
| void | alloc_async (Executable *flow) |
| Get a free item out of the pool. | |
Protected Member Functions | |
| BufferBase * | alloc_untyped (size_t size, Executable *flow) override |
| Internal helper funciton used by the Buffer implementation. | |
| void | free (BufferBase *item) override |
| Function called when a buffer refcount reaches zero. | |
Protected Member Functions inherited from Pool | |
| Pool () | |
| Default Constructor. | |
| virtual | ~Pool () |
| default destructor. | |
Private Member Functions | |
| Pool * | base_pool () |
Private Member Functions inherited from Atomic | |
| void | lock () |
| void | unlock () |
Private Attributes | |
| uint16_t | itemSize_ |
| How many bytes each entry should be. | |
| uint16_t | freeCount_ |
| How many entries can still be allocated. | |
| Pool * | basePool_ |
| Where to allocate memory from. | |
| Q | waitingQueue_ |
| Async allocators waiting for free buffers. | |
Additional Inherited Members | |
Static Public Member Functions inherited from Pool | |
| template<class BufferType > | |
| static void | alloc_async_init (BufferBase *base, Buffer< BufferType > **result) |
| Cast the result of an asynchronous allocation and perform a placement new on it. | |
Protected Attributes inherited from Pool | |
| size_t | totalSize |
| keep track of total allocated size of memory | |
Implementation of a Pool interface that takes memory from mainBufferPool (configurable) but limits the number of buffers allocatable.
Later async allocations will be blocked until an earlier buffer gets freed. Freed buffers go back to the underlying pool, so no memory is captive in this object.
Definition at line 47 of file LimitedPool.hxx.
|
inline |
| entry_size | is the byte size of the objects to be allocated. Usually sizeof(Buffer<YourType>). |
| entry_count | max number of buffer that can be allocated via this pool. |
| base_pool | where to allocate the memory for our objects. If nullptr, uses the mainBufferPool. |
Definition at line 56 of file LimitedPool.hxx.
|
inlineoverrideprotectedvirtual |
Internal helper funciton used by the Buffer implementation.
Implements Pool.
Definition at line 80 of file LimitedPool.hxx.
|
inlineprivate |
Definition at line 135 of file LimitedPool.hxx.
|
inlineoverrideprotectedvirtual |
Function called when a buffer refcount reaches zero.
Implements Pool.
Definition at line 111 of file LimitedPool.hxx.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Number of free items in the pool for a given allocation size.
| size | size of interest |
Implements Pool.
Definition at line 73 of file LimitedPool.hxx.
|
private |
Where to allocate memory from.
Definition at line 149 of file LimitedPool.hxx.
|
private |
How many entries can still be allocated.
Definition at line 147 of file LimitedPool.hxx.
|
private |
How many bytes each entry should be.
Definition at line 145 of file LimitedPool.hxx.
|
private |
Async allocators waiting for free buffers.
Definition at line 151 of file LimitedPool.hxx.