RAUL 0.8.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions
Raul::SRMWQueue< T > Class Template Reference
Realtime Audio Utility Library

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

`#include <SRMWQueue.hpp>`

Inherits noncopyable.

List of all members.

## Public Member Functions

| SRMWQueue (size_t size)
size_t | capacity () const
bool | full () const
| Return whether the queue is full.
bool | push (const T &obj)
| Push an item onto the back of the SRMWQueue - realtime-safe, not thread-safe.
bool | empty () const
| Return whether 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::SRMWQueue< T >

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

Implemented as a dequeue in a fixed array. Both push and pop are realtime safe, but only push is threadsafe. In other words, multiple threads can push data into this queue for a single thread to consume.

The interface is intentionally as similar to std::queue as possible, but note the additional thread restrictions imposed (e.g. empty() is only legal to call in the read thread).

Obey the threading restrictions documented here, or horrible nasty (possibly undetected) errors will occur.

If you only need a single writer, use SRSWQueue. This is slightly more computationally expensive, and allocates an additional size words of memory (ie if you're using this for ints or pointers etc, SRMWQueue will be twice the size of SRSWQueue for the same queue size. Additionally, the size of this queue must be a power of 2 (SRSWQueue does not have this limitation).

## Member Function Documentation

template<typename T >

bool Raul::SRMWQueue< T >::full | ( |  | ) | const`[inline]`

Return whether the queue is full.

Write thread(s) only.

template<typename T >

bool Raul::SRMWQueue< T >::push | ( | const T & | elem | ) | `[inline]`

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

Write thread(s) only.

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

template<typename T >

bool Raul::SRMWQueue< T >::empty | ( |  | ) | const`[inline]`

Return whether the queue is empty.

Read thread only.

template<typename T >

T & Raul::SRMWQueue< T >::front | ( |  | ) | const`[inline]`

Return the element at the front of the queue without removing it.

It is a fatal error to call front() when the queue is empty. Read thread only.

template<typename T >

void Raul::SRMWQueue< 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() if the queue is empty. Read thread only.

Returns:
  true if queue is now empty, otherwise false.

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

- SRMWQueue.hpp