|
EchoMap 2026-07-25 6d3977c
An experimental cross-platform digital signal processing application for sound-source localisation.
|
Provides a straightforward thread-safe double-ended queue implementation. More...
#include <ThreadSafeQueue.hpp>
Public Member Functions | |
| void | produce (ValueT value) |
| Enqueue a value. | |
| std::optional< ValueT > | try_consume () |
| Attempt to dequeue a value. | |
| std::optional< ValueT > | wait_consume (std::stop_token stop_token) |
| Attempt to dequeue a value. | |
| bool | empty () const |
| Checks the state of the queue. | |
| void | clear () |
| Empties the queue. | |
Private Attributes | |
| std::mutex | mutex |
| std::condition_variable_any | cv |
| std::deque< ValueT > | queue |
Provides a straightforward thread-safe double-ended queue implementation.
Values of the templated type may be enqueued ("produced") and dequeued ("consumed") in a blocking or non-blocking (but interruptable) model. All operations are atomic.
| ValueT | The type of values to be queued. |
Definition at line 29 of file ThreadSafeQueue.hpp.
|
inline |
Empties the queue.
Definition at line 106 of file ThreadSafeQueue.hpp.
|
inlinenodiscard |
Checks the state of the queue.
Definition at line 97 of file ThreadSafeQueue.hpp.
|
inline |
Enqueue a value.
| value | The value to enqueue. |
Definition at line 37 of file ThreadSafeQueue.hpp.
|
inline |
Attempt to dequeue a value.
This function does not block.
Definition at line 53 of file ThreadSafeQueue.hpp.
|
inline |
Attempt to dequeue a value.
This function blocks until interrupted by the stop token or a value is available on the queue.
| stop_token | The interrupt token for the thread block. |
Definition at line 75 of file ThreadSafeQueue.hpp.
|
private |
Definition at line 114 of file ThreadSafeQueue.hpp.
|
mutableprivate |
Definition at line 113 of file ThreadSafeQueue.hpp.
|
private |
Definition at line 115 of file ThreadSafeQueue.hpp.