18 #ifndef LUNCHBOX_LFQUEUE_H
19 #define LUNCHBOX_LFQUEUE_H
21 #include <lunchbox/atomic.h>
22 #include <lunchbox/debug.h>
23 #include <lunchbox/thread.h>
42 template<
typename T >
class LFQueue :
public boost::noncopyable
47 : _data( size + 1 ), _readPos( 0 ), _writePos( 0 ) {}
53 bool isEmpty()
const {
return _readPos == _writePos; }
64 void resize(
const int32_t size );
74 bool pop( T& result );
93 bool push(
const T& element );
102 std::vector< T > _data;
106 LB_TS_VAR( _reader );
107 LB_TS_VAR( _writer );
111 #include "lfQueue.ipp"
113 #endif // LUNCHBOX_LFQUEUE_H
bool pop(T &result)
Retrieve and pop the front element from the queue.
LFQueue(const int32_t size)
Construct a new queue.
void clear()
Reset (empty) the queue.
void resize(const int32_t size)
Resize and reset the queue.
bool getFront(T &result)
Retrieve the front element from the queue.
A thread-safe, lock-free queue with non-blocking access.
size_t getCapacity() const
~LFQueue()
Destruct this queue.
bool push(const T &element)
Push a new element to the back of the queue.