YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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>

+ Inheritance diagram for yarp::dev::impl::FixedSizeBuffersManager< T >:

Public Member Functions

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

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 82 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 69 of file FixedSizeBuffersManager-inl.h.

◆ ~FixedSizeBuffersManager()

Destructor.

Delete all allocated buffers.

Definition at line 181 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 84 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 190 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 169 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 153 of file FixedSizeBuffersManager-inl.h.


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