Realtime-safe single-reader single-writer queue (aka lock-free ringbuffer). More...
#include <SRSWQueue.hpp>
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. |
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).
Raul::SRSWQueue< T >::SRSWQueue | ( | size_t | size | ) | [explicit] |
size | Size in number of elements |
bool Raul::SRSWQueue< T >::push | ( | const T & | elem | ) | [inline] |
Push an item onto the back of the SRSWQueue - realtime-safe, not thread-safe.
References Raul::SRSWQueue< T >::full().
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.
References Raul::SRSWQueue< T >::empty().