RAUL  0.8.0
Public Member Functions | List of all members
Raul::SRSWQueue< T > Class Template Reference

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

#include <SRSWQueue.hpp>

Inherits noncopyable.

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. More...
 
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. More...
 

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
sizeSize 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().

Referenced by Raul::Maid::push().

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: