Pool
Pool objects in C++ are referenced by the following shared pointer typedef:
-
typedef std::shared_ptr<rogue::interfaces::stream::Pool> rogue::interfaces::stream::PoolPtr
Alias for using shared pointer as PoolPtr.
The class description is shown below:
-
class Pool : public rogue::EnableSharedFromThis<rogue::interfaces::stream::Pool>
Stream pool class.
The stream Pool class is responsible for allocating and garbage collecting Frame objects and the Buffer objects they contain. The default mode is to allocate a Frame with a single Buffer of the requested sized. Alternatively the Pool class can operate in fixed buffer size mode. In this mode Buffer objects of a fixed sized are allocated, with a Frame containing enough Buffer to satisfy the original request. Normally Buffer data is freed when returned back to the Pool class. Alternatively a pool can be enabled if operating in fixed size mode. When a pool is enabled returned buffer data is stored in the pool for later allocation to a new requester. The pool size defines the maximum number of entries to allow in the pool.
A subclass can be created with intercepts the Frame requests and allocates Frame and Buffer objects from an alternative source such as a hardware DMA driver.
Subclassed by rogue::interfaces::stream::Slave
Public Functions
-
uint32_t getAllocBytes()
Get allocated memory.
Return the total bytes currently allocated. This value is incremented as buffers are allocated and decremented as buffers are freed.
Exposed as getAllocBytes() to Python
- Returns:
Total currently allocated bytes
-
uint32_t getAllocCount()
Get allocated buffer count.
Return the total number of buffers currently allocated. This value is incremented as buffers are allocated and decremented as buffers are freed.
Exposed as getAllocCount() to Python
- Returns:
Total currently allocated buffers
-
virtual void retBuffer(uint8_t *data, uint32_t meta, uint32_t size)
Method called to return Buffer data.
-
void setFixedSize(uint32_t size)
Set fixed size mode.
This method puts the allocator into fixed size mode.
Exposed as setFixedSize() to Python
- Parameters:
size – Fixed size value.
-
uint32_t getFixedSize()
Get fixed size mode.
Return state of fixed size mode.
Exposed as getFixedSize() to Python
- Returns:
Fixed size value or 0 if not in fixed size mode
-
void setPoolSize(uint32_t size)
Set buffer pool size.
Set the buffer pool size.
Exposed as setPoolSize() to Python
- Parameters:
size – Number of entries to keep in the pool
-
uint32_t getPoolSize()
Get pool size.
Return configured pool size
Exposed as getPoolSize() to Python
- Returns:
Pool size
Protected Functions
-
std::shared_ptr<rogue::interfaces::stream::Buffer> allocBuffer(uint32_t size, uint32_t *total)
Allocate and Create a Buffer.
This method is the default Buffer allocator. The requested buffer is created from either a malloc call or fulling a free entry from the memory pool if it is enabled. If fixed size is configured the size parameter is ignored and a Buffer is returned with the fixed size amount of memory. The passed total value is incremented by the allocated Buffer size. This method is protected to allow it to be called by a sub-class of Pool.
Not exposed to Python
-
std::shared_ptr<rogue::interfaces::stream::Buffer> createBuffer(void *data, uint32_t meta, uint32_t size, uint32_t alloc)
Create a Buffer with passed data block.
This method is used to create a Buffer with a pre-allocated block of memory. This can be used when the block of memory is allocated by a hardware DMA driver. This method is protected to allow it to be called by a sub-class of Pool.
Not exposed to Python
- Parameters:
data – Data pointer to pre-allocated memory block
meta – Meta data associated with pre-allocated memory block
size – Usable size of memory block (may be smaller than allocated size)
alloc – Allocated size of memory block (may be greater than requested size)
- Returns:
Allocated Buffer pointer as BufferPtr
-
void decCounter(uint32_t alloc)
Decrement Allocation counter.
Called in a sub-class to decrement the allocated byte count
Not exposed to Python
- Parameters:
alloc – Amount of memory be de-allocated.
-
uint32_t getAllocBytes()