![]() |
LibraryLink Utilities
3.0.1
Modern C++ wrapper over LibraryLink and WSTP
|
ThreadsafeQueue is a linked list of nodes which supports safe concurrent access to its head (removing elements) and tail (adding new elements).
ThreadsafeQueue is described in chapter 6 of A. Williams "C++ Concurrency in Action" 2nd Edition. This implementation contains only slight modifications and minor bugfixes.
| T | - type of the data stored in the Queue |
#include <Queue.h>
Public Types | |
| using | value_type = T |
| Value type of queue elements. More... | |
Public Member Functions | |
| ThreadsafeQueue () | |
| Create new empty queue. More... | |
| std::shared_ptr< value_type > | tryPop () |
| Get data from the queue if available. More... | |
| bool | tryPop (value_type &value) |
| Get data from the queue if available. More... | |
| std::shared_ptr< value_type > | waitPop () |
| Get data from the queue, possibly waiting for it. More... | |
| void | waitPop (value_type &value) |
| Get data from the queue, possibly waiting for it. More... | |
| void | push (value_type new_value) |
| Push new value to the end of the queue. More... | |
| bool | empty () const |
| Check if the queue is empty. More... | |
| using LLU::Async::ThreadsafeQueue< T >::value_type = T |
Value type of queue elements.
|
inline |
Create new empty queue.
| bool LLU::Async::ThreadsafeQueue< T >::empty |
Check if the queue is empty.
| void LLU::Async::ThreadsafeQueue< T >::push | ( | value_type | new_value | ) |
Push new value to the end of the queue.
This operation can be performed even with other thread popping a value from the queue at the same time.
| new_value | - value to be pushed to the queue |
| std::shared_ptr< T > LLU::Async::ThreadsafeQueue< T >::tryPop |
Get data from the queue if available.
If data is not available in the queue, the calling thread will not wait.
| bool LLU::Async::ThreadsafeQueue< T >::tryPop | ( | value_type & | value | ) |
Get data from the queue if available.
If data is not available in the queue, the calling thread will not wait.
| [out] | value | - reference to the data from the queue |
| std::shared_ptr< T > LLU::Async::ThreadsafeQueue< T >::waitPop |
Get data from the queue, possibly waiting for it.
| void LLU::Async::ThreadsafeQueue< T >::waitPop | ( | value_type & | value | ) |
Get data from the queue, possibly waiting for it.
| value | - reference to the data from the queue |