Lunchbox
1.16.0
Multi-threaded C++ toolbox library for all application developers creating high-performance multi-threaded programs.
|
A thread-safe, lock-free queue with non-blocking access. More...
#include <lfQueue.h>
Public Member Functions | |
LFQueue (const int32_t size) | |
Construct a new queue. More... | |
~LFQueue () | |
Destruct this queue. More... | |
bool | isEmpty () const |
void | clear () |
Reset (empty) the queue. More... | |
void | resize (const int32_t size) |
Resize and reset the queue. More... | |
bool | pop (T &result) |
Retrieve and pop the front element from the queue. More... | |
bool | getFront (T &result) |
Retrieve the front element from the queue. More... | |
bool | push (const T &element) |
Push a new element to the back of the queue. More... | |
size_t | getCapacity () const |
A thread-safe, lock-free queue with non-blocking access.
Typically used for caches and non-blocking communication between two threads.
Current implementation constraints:
Example:
|
inlineexplicit |
|
inline |
void lunchbox::LFQueue< T >::clear | ( | ) |
Reset (empty) the queue.
Definition at line 21 of file lfQueue.ipp.
Referenced by lunchbox::LFQueue< T >::isEmpty().
|
inline |
bool lunchbox::LFQueue< T >::getFront | ( | T & | result | ) |
Retrieve the front element from the queue.
result | the front value or unmodified |
Definition at line 50 of file lfQueue.ipp.
Referenced by lunchbox::LFQueue< T >::isEmpty().
|
inline |
Definition at line 57 of file lfQueue.h.
References lunchbox::LFQueue< T >::clear(), lunchbox::LFQueue< T >::getFront(), lunchbox::LFQueue< T >::pop(), lunchbox::LFQueue< T >::push(), and lunchbox::LFQueue< T >::resize().
bool lunchbox::LFQueue< T >::pop | ( | T & | result | ) |
Retrieve and pop the front element from the queue.
result | the front value or unmodified |
Definition at line 38 of file lfQueue.ipp.
Referenced by lunchbox::LFQueue< T >::isEmpty().
bool lunchbox::LFQueue< T >::push | ( | const T & | element | ) |
Push a new element to the back of the queue.
element | the element to add. |
Definition at line 61 of file lfQueue.ipp.
Referenced by lunchbox::LFQueue< T >::isEmpty().
void lunchbox::LFQueue< T >::resize | ( | const int32_t | size | ) |
Resize and reset the queue.
This method is not thread-safe. The queue has to be empty.
Definition at line 29 of file lfQueue.ipp.
Referenced by lunchbox::LFQueue< T >::isEmpty().