v2.0.0
Loading...
Searching...
No Matches
UTILSLIB::CircularBuffer< T > Class Template Reference

Thread-safe lock-free circular (ring) buffer for producer-consumer data exchange between threads. More...

#include <circularbuffer.h>

Public Types

typedef QSharedPointer< CircularBufferSPtr
typedef QSharedPointer< const CircularBufferConstSPtr

Public Member Functions

 CircularBuffer (unsigned int uiMaxNumElements)
 ~CircularBuffer ()
bool push (const T *pArray, unsigned int size)
bool push (const T &newElement)
bool pop (T &element)
void clear ()
void pause (bool)
int getFreeElementsRead ()
int getFreeElementsWrite ()

Detailed Description

template<typename T>
class UTILSLIB::CircularBuffer< T >

Thread-safe lock-free circular (ring) buffer for producer-consumer data exchange between threads.

TEMPLATE CIRCULAR BUFFER

Definition at line 68 of file circularbuffer.h.

Member Typedef Documentation

◆ ConstSPtr

template<typename T>
typedef QSharedPointer<const CircularBuffer> UTILSLIB::CircularBuffer< T >::ConstSPtr

Const shared pointer type for CircularBuffer.

Definition at line 72 of file circularbuffer.h.

◆ SPtr

template<typename T>
typedef QSharedPointer<CircularBuffer> UTILSLIB::CircularBuffer< T >::SPtr

Shared pointer type for CircularBuffer.

Definition at line 71 of file circularbuffer.h.

Constructor & Destructor Documentation

◆ CircularBuffer()

template<typename T>
UTILSLIB::CircularBuffer< T >::CircularBuffer ( unsigned int uiMaxNumElements)
explicit

Constructs a CircularBuffer.

Parameters
[in]uiMaxNumElementslength of buffer.

Definition at line 162 of file circularbuffer.h.

◆ ~CircularBuffer()

template<typename T>
UTILSLIB::CircularBuffer< T >::~CircularBuffer ( )

Destroys the CircularBuffer.

Definition at line 177 of file circularbuffer.h.

Member Function Documentation

◆ clear()

template<typename T>
void UTILSLIB::CircularBuffer< T >::clear ( )
inline

Clears the buffer.

Definition at line 255 of file circularbuffer.h.

◆ getFreeElementsRead()

template<typename T>
int UTILSLIB::CircularBuffer< T >::getFreeElementsRead ( )
inline

Returns the number of free elements for thread safe reading.

Definition at line 277 of file circularbuffer.h.

◆ getFreeElementsWrite()

template<typename T>
int UTILSLIB::CircularBuffer< T >::getFreeElementsWrite ( )
inline

Returns the number of free elements for thread safe reading.

Definition at line 285 of file circularbuffer.h.

◆ pause()

template<typename T>
void UTILSLIB::CircularBuffer< T >::pause ( bool bPause)
inline

Pauses the buffer. Skpis any incoming matrices and only pops zero matrices.

Definition at line 269 of file circularbuffer.h.

◆ pop()

template<typename T>
bool UTILSLIB::CircularBuffer< T >::pop ( T & element)
inline

Returns the first element (first in first out).

Returns
the first element.

Definition at line 227 of file circularbuffer.h.

◆ push() [1/2]

template<typename T>
bool UTILSLIB::CircularBuffer< T >::push ( const T & newElement)
inline

Adds an element at the end of the buffer.

Parameters
[in]newElementpointer to an Array which should be apend to the end.

Definition at line 208 of file circularbuffer.h.

◆ push() [2/2]

template<typename T>
bool UTILSLIB::CircularBuffer< T >::push ( const T * pArray,
unsigned int size )
inline

Adds a whole array at the end buffer.

Parameters
[in]pArraypointer to an Array which should be apend to the end.
[in]sizenumber of elements containing the array.

Definition at line 187 of file circularbuffer.h.


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