This implements a singly linked fifo queue, which uses a sentinel technique and the atomic_swap64 call for implementing non-blocking transfer of commands/data from multiple threads to a single reading thread.
More...
|
void | init_list (int size) |
| List initialisation, special case for when init should be later.
|
|
| AsyncQueueMT (int size=10, const char *name="anon AsyncQueueMT") |
| Constructor.
|
|
| ~AsyncQueueMT () |
| Destructor.
|
|
bool | notEmpty () const |
| Returns true if there is more than the sentinel.
|
|
bool | isEmpty () const |
| Returns true if there is no data to be read.
|
|
const T & | front () const |
| Peek at data without removing.
|
|
const T & | back () const |
| Peek at data without removing.
|
|
T & | front () |
| Access data.
|
|
T & | back () |
| Access data.
|
|
void | pop () |
| Remove element at head.
|
|
unsigned int | size () |
| Return the number of elements in the list.
|
|
void | push_back (const T &data) |
| Push back, with a writer, convenience method, involves an assigment of the to-be pushed object.
|
|
template<class... Args> |
void | emplace_back (Args &&... args) |
| Construct an element at the end of the asynchronous list.
|
|
template<
class T,
class Alloc = ListElementAllocator<T>>
class dueca::AsyncQueueMT< T, Alloc >
This implements a singly linked fifo queue, which uses a sentinel technique and the atomic_swap64 call for implementing non-blocking transfer of commands/data from multiple threads to a single reading thread.
By design, this is only thread-safe for a single reader and multiple writers, and only for the inserting and extracting.
Use the dueca::AsyncQueueWriter and dueca::AsyncQueueReader helpers for inserting and extracting data.
Accessing members in the list through the front() and back() functions is possible, but not locked in any way. As long as the single reading thread does it, using front() will be safe. Using back() will only be safe if there is no reading/pop() action, and no other threads write.