Public Member Functions

Raul::SRSWQueue< T > Class Template Reference
[Realtime Audio Utility Library]

Realtime-safe single-reader single-writer queue (aka lock-free ringbuffer). More...

#include <SRSWQueue.hpp>

Collaboration diagram for Raul::SRSWQueue< T >:
Collaboration graph

List of all members.

Public Member Functions

 SRSWQueue (size_t size)
size_t capacity () const
bool full () const
 Return whether or not the queue is full.
bool push (const T &obj)
 Push an item onto the back of the SRSWQueue - realtime-safe, not thread-safe.
bool empty () const
 Return whether or not the queue is empty.
T & front () const
 Return the element at the front of the queue without removing it.
void pop ()
 Pop an item off the front of the queue - realtime-safe, not thread-safe.

Detailed Description

template<typename T>
class Raul::SRSWQueue< T >

Realtime-safe single-reader single-writer queue (aka lock-free ringbuffer).

This is appropriate for a cross-thread queue of fixed size object. If you need to do variable sized reads and writes, use Raul::RingBuffer instead.

Implemented as a dequeue in a fixed array. This is read/write thread-safe, pushing and popping may occur simultaneously by seperate threads, but the push and pop operations themselves are not thread-safe (ie. there can be at most 1 read and at most 1 writer thread).


Constructor & Destructor Documentation

template<typename T >
Raul::SRSWQueue< T >::SRSWQueue ( size_t  size  )  [explicit]
Parameters:
size Size in number of elements

Member Function Documentation

template<typename T>
bool Raul::SRSWQueue< T >::push ( const T &  elem  )  [inline]

Push an item onto the back of the SRSWQueue - realtime-safe, not thread-safe.

Returns:
true if elem was successfully pushed onto the queue, false otherwise (queue is full).

References Raul::SRSWQueue< T >::full().

template<typename T >
void Raul::SRSWQueue< T >::pop (  )  [inline]

Pop an item off the front of the queue - realtime-safe, not thread-safe.

It is a fatal error to call pop() when the queue is empty.

Returns:
the element popped.

References Raul::SRSWQueue< T >::empty().


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