#include <SharedBuffer.hpp>
The SharedBuffer represents the combination of address and length, and a shared pointer that will automatically cleanup the memory.
Pothos::SharedBuffer::SharedBuffer |
( |
void |
| ) |
|
Pothos::SharedBuffer::SharedBuffer |
( |
const size_t |
address, |
|
|
const size_t |
length, |
|
|
std::shared_ptr< void > |
container |
|
) |
| |
Create a SharedBuffer from address, length, and the container. The container is any object that can be put into a shared_ptr. When the shared pointer is deleted, the container's destructor (written by the user) should handle the cleanup of the memory.
Pothos::SharedBuffer::SharedBuffer |
( |
const size_t |
address, |
|
|
const size_t |
length, |
|
|
const SharedBuffer & |
buffer |
|
) |
| |
Create a sub-buffer that is a subset of the buffer. The shared container is copied so the sub-buffer holds a reference.
- Exceptions
-
SharedBufferError | if the parameters would be out of bounds |
- Parameters
-
address | an address within the buffer |
length | the new length of the sub buffer |
buffer | a shared buffer which is a superset of this new one |
size_t Pothos::SharedBuffer::getAddress |
( |
void |
| ) |
const |
|
inline |
Get the address of the first byte of the buffer.
size_t Pothos::SharedBuffer::getAlias |
( |
void |
| ) |
const |
|
inline |
Get the alias address (non-zero for circular buffers). Address and alias will point to the same physical memory.
const std::shared_ptr< void > & Pothos::SharedBuffer::getContainer |
( |
void |
| ) |
const |
|
inline |
Get access to the underlying memory container.
size_t Pothos::SharedBuffer::getEnd |
( |
void |
| ) |
const |
|
inline |
Get the end address - front address + length. The end address is non-inclusive.
- Returns
- the end address
size_t Pothos::SharedBuffer::getLength |
( |
void |
| ) |
const |
|
inline |
Get the length of the buffer in bytes.
static SharedBuffer Pothos::SharedBuffer::make |
( |
const size_t |
numBytes, |
|
|
const long |
nodeAffinity = -1 |
|
) |
| |
|
static |
Create a SharedBuffer given a length in bytes. This factory allocates memory which is held by the SharedBuffer. When the SharedBuffer is deleted, the memory will be freed as well. The node affinity is used to allocate physical memory on a NUMA node.
- Parameters
-
numBytes | the number of bytes to allocate in this buffer |
nodeAffinity | which NUMA node to allocate on (-1 for dont care) |
- Returns
- a new shared buffer object
static SharedBuffer Pothos::SharedBuffer::makeCirc |
( |
const size_t |
numBytes, |
|
|
const long |
nodeAffinity = -1 |
|
) |
| |
|
static |
Create a circular SharedBuffer given a length in bytes. The rules for the circular or double mapping are as follows: for i in 0 to length-1: address + i == address + i + length
This factory allocates memory which is held by the SharedBuffer. When the SharedBuffer is deleted, the memory will be freed as well. The node affinity is used to allocate physical memory on a NUMA node.
- Parameters
-
numBytes | the number of bytes to allocate in this buffer |
nodeAffinity | which NUMA node to allocate on (-1 for dont care) |
- Returns
- a new circular shared buffer object
Pothos::SharedBuffer::operator bool |
( |
void |
| ) |
const |
|
inlineexplicit |
Is this shared buffer valid?
bool Pothos::SharedBuffer::unique |
( |
void |
| ) |
const |
|
inline |
Is this instance of this shared buffer unique?
- Returns
- true if this is the only copy
size_t Pothos::SharedBuffer::useCount |
( |
void |
| ) |
const |
|
inline |
The number of copies of this shared buffer.
The documentation for this class was generated from the following file: