18 #ifndef RAUL_SRSW_QUEUE_HPP
19 #define RAUL_SRSW_QUEUE_HPP
23 #include <boost/utility.hpp>
24 #include <raul/AtomicInt.hpp>
47 inline size_t capacity()
const {
return _size-1; }
52 inline bool full()
const;
53 inline bool push(
const T& obj);
58 inline bool empty()
const;
59 inline T&
front()
const;
75 , _objects((T*)calloc(_size, sizeof(T)))
82 SRSWQueue<T>::~SRSWQueue()
94 return (_back.get() == _front.get());
100 template <
typename T>
104 return (((_front.get() - _back.get() + _size) % _size) == 1);
110 template <
typename T>
114 return _objects[_front.get()];
123 template <
typename T>
130 unsigned back = _back.get();
131 _objects[back] = elem;
132 _back = (back + 1) % _size;
144 template <
typename T>
151 _front = (_front.get() + 1) % (_size);
157 #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:125
bool full() const
Return whether or not the queue is full.
Definition: SRSWQueue.hpp:102
void pop()
Pop an item off the front of the queue - realtime-safe, not thread-safe.
Definition: SRSWQueue.hpp:146
bool empty() const
Return whether or not the queue is empty.
Definition: SRSWQueue.hpp:92
T & front() const
Return the element at the front of the queue without removing it.
Definition: SRSWQueue.hpp:112
Realtime-safe single-reader single-writer queue (aka lock-free ringbuffer)
Definition: SRSWQueue.hpp:39