Pothos  0.7.0-gf7fbae99
The Pothos dataflow programming software suite
Public Member Functions | Static Public Member Functions | List of all members
Pothos::SharedBuffer Class Reference

#include <SharedBuffer.hpp>

Public Member Functions

 SharedBuffer (void)
 Create a null SharedBuffer. More...
 
 SharedBuffer (const size_t address, const size_t length, std::shared_ptr< void > container)
 
 SharedBuffer (const size_t address, const size_t length, const SharedBuffer &buffer)
 
size_t getAddress (void) const
 Get the address of the first byte of the buffer. More...
 
size_t getLength (void) const
 Get the length of the buffer in bytes. More...
 
size_t getAlias (void) const
 
size_t getEnd (void) const
 
bool unique (void) const
 
size_t useCount (void) const
 
 operator bool (void) const
 
const std::shared_ptr< void > & getContainer (void) const
 

Static Public Member Functions

static const SharedBuffernull (void)
 Get a const reference to a null/empty SharedBuffer. More...
 
static SharedBuffer make (const size_t numBytes, const long nodeAffinity=-1)
 
static SharedBuffer makeCirc (const size_t numBytes, const long nodeAffinity=-1)
 

Detailed Description

The SharedBuffer represents the combination of address and length, and a shared pointer that will automatically cleanup the memory.

Constructor & Destructor Documentation

◆ SharedBuffer() [1/3]

Pothos::SharedBuffer::SharedBuffer ( void  )

Create a null SharedBuffer.

◆ SharedBuffer() [2/3]

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.

◆ SharedBuffer() [3/3]

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
SharedBufferErrorif the parameters would be out of bounds
Parameters
addressan address within the buffer
lengththe new length of the sub buffer
buffera shared buffer which is a superset of this new one

Member Function Documentation

◆ getAddress()

size_t Pothos::SharedBuffer::getAddress ( void  ) const
inline

Get the address of the first byte of the buffer.

◆ getAlias()

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.

◆ getContainer()

const std::shared_ptr< void > & Pothos::SharedBuffer::getContainer ( void  ) const
inline

Get access to the underlying memory container.

◆ getEnd()

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

◆ getLength()

size_t Pothos::SharedBuffer::getLength ( void  ) const
inline

Get the length of the buffer in bytes.

◆ make()

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
numBytesthe number of bytes to allocate in this buffer
nodeAffinitywhich NUMA node to allocate on (-1 for dont care)
Returns
a new shared buffer object

◆ makeCirc()

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
numBytesthe number of bytes to allocate in this buffer
nodeAffinitywhich NUMA node to allocate on (-1 for dont care)
Returns
a new circular shared buffer object

◆ null()

static const SharedBuffer& Pothos::SharedBuffer::null ( void  )
static

Get a const reference to a null/empty SharedBuffer.

◆ operator bool()

Pothos::SharedBuffer::operator bool ( void  ) const
inlineexplicit

Is this shared buffer valid?

◆ unique()

bool Pothos::SharedBuffer::unique ( void  ) const
inline

Is this instance of this shared buffer unique?

Returns
true if this is the only copy

◆ useCount()

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: