|
Open Model Railroad Network (OpenMRN)
|
Pool of fixed number of items which can be allocated up on request. More...
#include <Buffer.hxx>
Public Member Functions | |
| bool | valid (QMember *item) |
| Used in static pools to tell if this item is a member of the pool. | |
| FixedPool (size_t item_size, size_t items) | |
| Constructor for a fixed size pool. | |
| ~FixedPool () | |
| default destructor | |
| 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. | |
Public Member Functions inherited from Atomic | |
| void | lock () |
| void | unlock () |
Protected Attributes | |
| Q | queue |
| Free buffer queue. | |
| char * | mempool |
| First buffer in a pre-allocated array pool. | |
| size_t | itemSize |
| item Size for fixed pools | |
| size_t | items |
| total number of items in the queue | |
| bool | empty |
| is the pool empty | |
Protected Attributes inherited from Pool | |
| size_t | totalSize |
| keep track of total allocated size of memory | |
Private Member Functions | |
| BufferBase * | alloc_untyped (size_t size, Executable *flow) override |
| Get a free item out of the pool. | |
| void | free (BufferBase *item) override |
| Release an item back to the free pool. | |
| FixedPool () | |
| Default Constructor. | |
| DISALLOW_COPY_AND_ASSIGN (FixedPool) | |
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 Member Functions inherited from Pool | |
| Pool () | |
| Default Constructor. | |
| virtual | ~Pool () |
| default destructor. | |
Pool of fixed number of items which can be allocated up on request.
Definition at line 572 of file Buffer.hxx.
|
inline |
Constructor for a fixed size pool.
| item_size | size of each item in the pool (including the Buffer wrapper). |
| items | number of items in the pool |
Definition at line 594 of file Buffer.hxx.
|
inline |
default destructor
Definition at line 612 of file Buffer.hxx.
|
overrideprivatevirtual |
Get a free item out of the pool.
| size | the number of bytes of the buffer payload that we need to allocate. |
| flow | if !NULL, then the alloc call is considered async and will behave as if alloc_async() was called. |
| size | how many payload bytes should he allocated buffer have. Usually sizeof<T> for Buffer<T>. |
| flow | if !NULL, then the alloc call is considered async and will behave as if alloc_async() was called. |
Implements Pool.
Definition at line 197 of file Buffer.cxx.
|
overrideprivatevirtual |
Release an item back to the free pool.
| item | pointer to item to release |
Implements Pool.
Definition at line 231 of file Buffer.cxx.
|
inlineoverridevirtual |
Number of free items in the pool.
Implements Pool.
Definition at line 620 of file Buffer.hxx.
|
inlineoverridevirtual |
Number of free items in the pool for a given allocation size.
| size | size of interest |
Implements Pool.
Definition at line 629 of file Buffer.hxx.
Used in static pools to tell if this item is a member of the pool.
| item | to test validity on |
Definition at line 579 of file Buffer.hxx.
|
protected |
is the pool empty
Definition at line 648 of file Buffer.hxx.
|
protected |
total number of items in the queue
Definition at line 645 of file Buffer.hxx.
|
protected |
item Size for fixed pools
Definition at line 642 of file Buffer.hxx.
|
protected |
First buffer in a pre-allocated array pool.
Definition at line 639 of file Buffer.hxx.
|
protected |
Free buffer queue.
Definition at line 636 of file Buffer.hxx.