YARP
Yet Another Robot Platform
yarp::dev::impl::FixedSizeBuffersManager< T > Class Template Reference

A manager of fixed size buffers in multi-thread environment. More...

#include <yarp/dev/impl/FixedSizeBuffersManager.h>

Public Member Functions

 FixedSizeBuffersManager (uint32_t sizeOfBuffers, std::size_t initialNumOfBuffers=3)
 Constructor. More...
 
 ~FixedSizeBuffersManager ()
 Destructor. More...
 
Buffer< T > getBuffer ()
 Get a buffer and fill its information in @buffer. More...
 
std::size_t getBufferSize ()
 Get the number of elements of a buffer. More...
 
void releaseBuffer (Buffer< T > &buffer)
 Release a buffer. More...
 
void printBuffers ()
 Prints info of buffers. More...
 

Detailed Description

template<typename T>
class yarp::dev::impl::FixedSizeBuffersManager< T >

A manager of fixed size buffers in multi-thread environment.

When it is created it allocates initialNumOfBuffers buffers of size sizeOfBuffers. The user can get a buffer, uses and releases it when he/she doesn't need anymore. If all buffers are busy and a new buffer is required, than the manager creates new one.

Definition at line 87 of file FixedSizeBuffersManager.h.

Constructor & Destructor Documentation

◆ FixedSizeBuffersManager()

template<typename T >
yarp::dev::impl::FixedSizeBuffersManager< T >::FixedSizeBuffersManager ( uint32_t  sizeOfBuffers,
std::size_t  initialNumOfBuffers = 3 
)
explicit

Constructor.

Allocate initialNumOfBuffers buffers of size sizeOfBuffers.

Definition at line 72 of file FixedSizeBuffersManager-inl.h.

◆ ~FixedSizeBuffersManager()

Destructor.

Delete all allocated buffers.

Definition at line 184 of file FixedSizeBuffersManager-inl.h.

Member Function Documentation

◆ getBuffer()

template<typename T >
yarp::dev::impl::Buffer< T > yarp::dev::impl::FixedSizeBuffersManager< T >::getBuffer

Get a buffer and fill its information in @buffer.

Note
A buffer is always available unless a std::bad_alloc is thrown, therefore use statement catch to guarantee the required buffer is not null.

Definition at line 87 of file FixedSizeBuffersManager-inl.h.

◆ getBufferSize()

template<typename T >
std::size_t yarp::dev::impl::FixedSizeBuffersManager< T >::getBufferSize

Get the number of elements of a buffer.

Definition at line 193 of file FixedSizeBuffersManager-inl.h.

◆ printBuffers()

template<typename T >
void yarp::dev::impl::FixedSizeBuffersManager< T >::printBuffers

Prints info of buffers.

Function for debug purpose

Definition at line 172 of file FixedSizeBuffersManager-inl.h.

◆ releaseBuffer()

template<typename T >
void yarp::dev::impl::FixedSizeBuffersManager< T >::releaseBuffer ( Buffer< T > &  buffer)

Release a buffer.

This function should be used by user when he/she doesn't need it anymore. It releases a buffer in constant time.

Parameters
[in]buffer

Definition at line 156 of file FixedSizeBuffersManager-inl.h.


The documentation for this class was generated from the following files: