Pothos  0.3.3-g32d3017c
The Pothos dataflow programming software suite
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
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
 
pothos_explicit operator bool (void) const
 
const std::shared_ptr< void > & getContainer (void) const
 

Static Public Member Functions

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

Pothos::SharedBuffer::SharedBuffer ( void  )

Create a null SharedBuffer.

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
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

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
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
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
Pothos::SharedBuffer::operator bool ( void  ) const
inline

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: