18 #ifndef RAUL_SRSW_QUEUE_HPP 19 #define RAUL_SRSW_QUEUE_HPP 23 #include <boost/utility.hpp> 25 #include "raul/AtomicInt.hpp" 52 inline size_t capacity()
const {
return _size-1; }
57 inline bool full()
const;
58 inline bool push(
const T& obj);
63 inline bool empty()
const;
64 inline T&
front()
const;
80 , _objects(new T[_size])
99 return (_back.get() == _front.get());
105 template <
typename T>
109 return (((_front.get() - _back.get() + _size) % _size) == 1);
115 template <
typename T>
119 return _objects[_front.get()];
128 template <
typename T>
135 unsigned back = _back.get();
136 _objects[back] = elem;
137 _back = (back + 1) % _size;
149 template <
typename T>
156 _front = (_front.get() + 1) % (_size);
162 #endif // RAUL_SRSW_QUEUE_HPP bool push(const T &obj)
Push an item onto the back of the SRSWQueue - realtime-safe, not thread-safe.
Definition: SRSWQueue.hpp:130
bool full() const
Return whether or not the queue is full.
Definition: SRSWQueue.hpp:107
SRSWQueue(size_t size)
Definition: SRSWQueue.hpp:76
void pop()
Pop an item off the front of the queue - realtime-safe, not thread-safe.
Definition: SRSWQueue.hpp:151
bool empty() const
Return whether or not the queue is empty.
Definition: SRSWQueue.hpp:97
Atomic integer.
Definition: AtomicInt.hpp:29
T & front() const
Return the element at the front of the queue without removing it.
Definition: SRSWQueue.hpp:117
Realtime-safe single-reader single-writer queue (aka lock-free ringbuffer)
Definition: SRSWQueue.hpp:43