Thread-safe queue with blocking and shutdown-aware consumers.
More...
#include <src/thread_safe.h>
|
| bool | peek () |
| | Inspect the next queued value without popping it.
|
| status_t | pop () |
| | Remove and return the next queued item, waiting when requested.
|
| template<class Rep, class Period> |
| status_t | pop (std::chrono::duration< Rep, Period > delay) |
| | Remove and return the next queued item, waiting when requested.
|
| | queue_t (std::uint32_t max_elements=32, overflow_policy_e overflow=overflow_policy_e::drop_oldest) |
| | Construct a bounded blocking queue.
|
| template<class... Args> |
| bool | raise (Args &&...args) |
| | Notify waiters that a new event value may be available.
|
| bool | running () const |
| | Return whether the queue is still running.
|
|
void | stop () |
| | Shut down the queue and wake blocked consumers.
|
| std::vector< T > & | unsafe () |
| | Return the wrapped pointer without synchronization checks.
|
template<class T>
class safe::queue_t< T >
Thread-safe queue with blocking and shutdown-aware consumers.
◆ overflow_policy_e
Behavior when raise() is called with the queue already at its bound.
| Enumerator |
|---|
| drop_oldest | Clear the queue and accept the new item (current default behavior).
|
| reject | Refuse the new item, leaving existing queued items intact.
|
◆ queue_t()
Construct a bounded blocking queue.
- Parameters
-
| max_elements | Maximum number of elements that may be queued. |
| overflow | Behavior when the queue reaches its maximum size. |
◆ peek()
Inspect the next queued value without popping it.
- Returns
- True when a value is available to inspect.
◆ pop() [1/2]
Remove and return the next queued item, waiting when requested.
- Returns
- Removed queue item, or empty result when the queue is stopped or empty.
◆ pop() [2/2]
template<class T>
template<class Rep, class Period>
Remove and return the next queued item, waiting when requested.
- Parameters
-
| delay | Maximum wait duration before timing out. |
- Returns
- Removed queue item, or empty result when the queue is stopped or empty.
◆ raise()
template<class T>
template<class... Args>
Notify waiters that a new event value may be available.
- Parameters
-
| args | Arguments forwarded to the callable or parser. |
- Returns
- True if the item was queued, false if the queue is stopped or the configured overflow policy rejects the item.
◆ running()
Return whether the queue is still running.
- Returns
- True while the queue accepts producers and consumers.
◆ unsafe()
Return the wrapped pointer without synchronization checks.
- Returns
- Mutable queue storage for callers that already hold external synchronization.
The documentation for this class was generated from the following file: