|
rogue
|
Frame and buffer allocator for stream endpoints. More...
#include <Pool.h>
Public Member Functions | |
| Pool () | |
| Constructs a pool with default allocation behavior enabled. | |
| virtual | ~Pool () |
| Destroys the pool and releases any cached buffer storage. | |
| uint32_t | getAllocBytes () |
| Returns total currently allocated bytes. | |
| uint32_t | getAllocCount () |
| Returns total currently allocated buffer count. | |
| virtual std::shared_ptr< rogue::interfaces::stream::Frame > | acceptReq (uint32_t size, bool zeroCopyEn) |
| Services a frame allocation request from a master. | |
| virtual void | retBuffer (uint8_t *data, uint32_t meta, uint32_t size) |
| Returns buffer data to the allocator. | |
| void | setFixedSize (uint32_t size) |
| Sets fixed-size mode. | |
| uint32_t | getFixedSize () |
| Returns fixed-size allocation setting. | |
| void | setPoolSize (uint32_t size) |
| Sets buffer pool size. | |
| uint32_t | getPoolSize () |
| Returns configured maximum number of cached pool entries. | |
Public Member Functions inherited from rogue::EnableSharedFromThis< rogue::interfaces::stream::Pool > | |
| std::shared_ptr< rogue::interfaces::stream::Pool > | shared_from_this () |
Returns a shared_ptr<T> for this instance. | |
Public Member Functions inherited from rogue::EnableSharedFromThisBase | |
| virtual | ~EnableSharedFromThisBase () |
| Virtual destructor for polymorphic base usage. | |
Static Public Member Functions | |
| static void | setup_python () |
| Registers this type with Python bindings. | |
Protected Member Functions | |
| std::shared_ptr< rogue::interfaces::stream::Buffer > | allocBuffer (uint32_t size, uint32_t *total) |
| Allocate a buffer passed size. | |
| std::shared_ptr< rogue::interfaces::stream::Buffer > | createBuffer (void *data, uint32_t meta, uint32_t size, uint32_t alloc) |
| Creates a Buffer with a pre-allocated data block. | |
| void | decCounter (uint32_t alloc) |
| Decrements allocation counter. | |
Frame and buffer allocator for stream endpoints.
Pool is the stream-memory allocation layer used by Slave objects to service frame requests from upstream Master objects (Master::reqFrame() eventually resolves through Pool::acceptReq() on the primary slave).
Core responsibilities:
Frame objects.Buffer objects used by each frame.getAllocBytes(), getAllocCount()).Default behavior:
Fixed-size mode (setFixedSize()):
Pooling mode (setPoolSize() with fixed-size operation):
Subclassing/advanced use:
acceptReq() to customize how frames are assembled.retBuffer() to customize return/recycle behavior.allocBuffer(), createBuffer(), decCounter()) when integrating external memory providers, such as DMA-backed memory. | rogue::interfaces::stream::Pool::Pool | ( | ) |
Constructs a pool with default allocation behavior enabled.
Creator.
Description: Stream memory pool The function calls in this are a mess! create buffer, allocate buffer, etc
This file is part of the rogue software platform. It is subject to the license terms in the LICENSE.txt file found in the top-level directory of this distribution and at: https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. No part of the rogue software platform, including this file, may be copied, modified, propagated, or distributed except according to the terms
|
virtual |
|
virtual |
Services a frame allocation request from a master.
Accept a frame request. Called from master.
Called by Master::reqFrame() to allocate a frame and one or more buffers.
| size | Minimum requested payload size in bytes. |
| zeroCopyEn | True to allow zero-copy buffers when supported. |
Reimplemented in rogue::hardware::axi::AxiStreamDma, rogue::protocols::packetizer::Application, rogue::protocols::rssi::Application, rogue::utilities::StreamUnZip, and rogue::utilities::StreamZip.
|
protected |
Allocate a buffer passed size.
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
| size | Buffer size requested |
| total | Pointer to current total size |
|
protected |
Creates a Buffer with a pre-allocated data block.
Create a Buffer with passed data.
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
| 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) |
|
protected |
| uint32_t rogue::interfaces::stream::Pool::getAllocBytes | ( | ) |
Returns total currently allocated bytes.
Get allocated memory.
This value is incremented as buffers are allocated and decremented as buffers are freed.
Exposed as getAllocBytes() in Python.
| uint32_t rogue::interfaces::stream::Pool::getAllocCount | ( | ) |
Returns total currently allocated buffer count.
Get allocated count.
This value is incremented as buffers are allocated and decremented as buffers are freed.
Exposed as getAllocCount() in Python.
| uint32_t rogue::interfaces::stream::Pool::getFixedSize | ( | ) |
Returns fixed-size allocation setting.
Get fixed size mode.
A return value of 0 means fixed-size mode is disabled.
Exposed as getFixedSize() in Python.
0 when fixed-size mode is disabled. | uint32_t rogue::interfaces::stream::Pool::getPoolSize | ( | ) |
Returns configured maximum number of cached pool entries.
Get pool size.
Exposed as getPoolSize() in Python.
|
virtual |
Returns buffer data to the allocator.
Return a buffer.
This method is called by the Buffer destructor in order to free the associated Buffer memory. May be overridden by a subclass to change the way the buffer data is returned.
| data | Data pointer to release. |
| meta | Metadata specific to the allocator. |
| size | Size of data buffer. |
Reimplemented in rogue::hardware::axi::AxiStreamDma.
| void rogue::interfaces::stream::Pool::setFixedSize | ( | uint32_t | size | ) |
Sets fixed-size mode.
Set fixed size mode.
This method puts the allocator into fixed size mode.
Exposed as setFixedSize() in Python.
| size | Fixed size value. |
| void rogue::interfaces::stream::Pool::setPoolSize | ( | uint32_t | size | ) |
Sets buffer pool size.
Set buffer pool size.
Exposed as setPoolSize() in Python.
| size | Number of entries to keep in the pool. |
|
static |