libUTL++
utl::RingBuffer< T, nullValue > Class Template Reference

Thread-safe fixed-size queue. More...

#include <RingBuffer.h>

Public Member Functions

void set (size_t size)
 Initialize. More...
 
void reset ()
 Reset to default state. More...
 
size_t count () const
 Sample a lower-bound on the number of contained items. More...
 
bool enQ (T value)
 Try to queue an object. More...
 
bool deQ (T &value)
 Try to dequeue an object. More...
 
void forEach (std::function< void(T)> f) const
 Execute the given function on each contained value (not thread-safe!). More...
 

Detailed Description

template<typename T, T nullValue = T()>
class utl::RingBuffer< T, nullValue >

Thread-safe fixed-size queue.

Author
Adam McKee

Definition at line 19 of file RingBuffer.h.

Member Function Documentation

◆ set()

template<typename T , T nullValue>
void utl::RingBuffer< T, nullValue >::set ( size_t  size)

Initialize.

Definition at line 105 of file RingBuffer.h.

References ASSERTD.

◆ reset()

template<typename T , T nullValue>
void utl::RingBuffer< T, nullValue >::reset ( )

Reset to default state.

Definition at line 144 of file RingBuffer.h.

◆ count()

template<typename T, T nullValue = T()>
size_t utl::RingBuffer< T, nullValue >::count ( ) const
inline

Sample a lower-bound on the number of contained items.

Definition at line 46 of file RingBuffer.h.

◆ enQ()

template<typename T , T nullValue>
bool utl::RingBuffer< T, nullValue >::enQ ( value)

Try to queue an object.

Parameters
valuethe value to en-q
Returns
true iff 'value' was queued

Definition at line 157 of file RingBuffer.h.

◆ deQ()

template<typename T , T nullValue>
bool utl::RingBuffer< T, nullValue >::deQ ( T &  value)

Try to dequeue an object.

Parameters
valuetarget instance of T
Returns
true iff the head value was copied into 'value'

Definition at line 186 of file RingBuffer.h.

◆ forEach()

template<typename T , T nullValue>
void utl::RingBuffer< T, nullValue >::forEach ( std::function< void(T)>  f) const

Execute the given function on each contained value (not thread-safe!).

Definition at line 214 of file RingBuffer.h.

References ASSERTD.


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