DUECA/DUSIME
|
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...
Public Types | |
typedef T | value_type |
Type of the objects in the queue. | |
Public Member Functions | |
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. More... | |
~AsyncQueueMT () | |
Destructor. More... | |
bool | notEmpty () const |
Returns true if there is more than the sentinel. More... | |
bool | isEmpty () const |
Returns true if there is no data to be read. More... | |
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. More... | |
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. More... | |
Public Attributes | |
Alloc | allocator |
Allocator used. More... | |
Friends | |
class | AsyncQueueWriter< T, Alloc > |
only access to writing data on the queue | |
class | AsyncQueueReader< T, Alloc > |
only point of access for reading data from the queue | |
Alloc::element_ptr | get_list_spare (AsyncQueueMT< T, Alloc > &list) |
friend function for accessing an element from the spare stack More... | |
void | write_list_back (AsyncQueueMT< T, Alloc > &list, typename Alloc::element_ptr elt) |
write back a previously obtained spare More... | |
void | return_list_elt (AsyncQueueMT< T, Alloc > &list, typename Alloc::element_ptr elt) |
return a previously obtained spare to the spares More... | |
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.
|
inline |
Constructor.
|
inline |
Destructor.
|
inline |
Returns true if there is more than the sentinel.
|
inline |
Returns true if there is no data to be read.
|
inline |
Return the number of elements in the list.
|
inline |
Construct an element at the end of the asynchronous list.
args | Arguments for constructing the element. |
|
friend |
friend function for accessing an element from the spare stack
Note that you are responsible for returning this element with write_list_back or return_list_spare
T | Type of object |
Alloc | Memory allocator/handler for this list |
list | List object |
|
friend |
write back a previously obtained spare
Note that you are responsible for obtaining this element with get_list_spare
T | Type of object. |
Alloc | Memory allocator/handler for this list. |
list | List object. |
elt | Element to append. |
|
friend |
return a previously obtained spare to the spares
Note that you are responsible for obtaining this element with get_list_spare. Note: either recycle or append, do not do both!
T | Type of object. |
Alloc | Memory allocator/handler for this list. |
list | List object. |
elt | Element to recycle. |
Alloc dueca::AsyncQueueMT< T, Alloc >::allocator |
Allocator used.
Normally (default allocator) not modifyable, but custom allocators may be tuned.