|
Radix Relay
Hybrid mesh communications with Signal Protocol encryption
|
Thread-safe asynchronous queue for message passing between coroutines. More...
#include <async_queue.hpp>
Public Member Functions | |
| async_queue (const std::shared_ptr< boost::asio::io_context > &io_context) | |
| Constructs a new async queue. | |
| async_queue (const async_queue &)=delete | |
| auto | operator= (const async_queue &) -> async_queue &=delete |
| async_queue (async_queue &&)=delete | |
| auto | operator= (async_queue &&) -> async_queue &=delete |
| ~async_queue ()=default | |
| auto | push (T value) -> void |
| Pushes a value onto the queue (non-blocking). | |
| auto | pop (std::shared_ptr< boost::asio::cancellation_slot > cancel_slot=nullptr) -> boost::asio::awaitable< T > |
| Asynchronously pops a value from the queue (coroutine). | |
| auto | try_pop () -> std::optional< T > |
| Attempts to pop a value without blocking. | |
| auto | empty () const -> bool |
| Checks if the queue is empty. | |
| auto | size () const -> std::size_t |
| Returns the current number of elements in the queue. | |
| auto | close () -> void |
| Closes the queue, preventing further operations. | |
Static Public Attributes | |
| static const std::size_t | channel_size { 1024 } |
| Maximum number of elements the queue can hold. | |
Thread-safe asynchronous queue for message passing between coroutines.
| T | The type of elements stored in the queue |
Provides thread-safe push/pop operations using Boost.Asio concurrent channels. Supports coroutine-based async pop operations with optional cancellation.
Definition at line 25 of file async_queue.hpp.
|
inlineexplicit |
Constructs a new async queue.
| io_context | Shared pointer to the Boost.Asio io_context for async operations |
Definition at line 36 of file async_queue.hpp.
|
delete |
|
delete |
|
default |
|
inline |
Closes the queue, preventing further operations.
Definition at line 119 of file async_queue.hpp.
|
inline |
Checks if the queue is empty.
Definition at line 107 of file async_queue.hpp.
|
delete |
|
delete |
|
inline |
Asynchronously pops a value from the queue (coroutine).
| cancel_slot | Optional cancellation slot for operation cancellation |
| boost::system::system_error | on cancellation or channel errors |
Definition at line 64 of file async_queue.hpp.
|
inline |
Pushes a value onto the queue (non-blocking).
| value | The value to push (moved into the queue) |
Definition at line 51 of file async_queue.hpp.
|
inline |
Returns the current number of elements in the queue.
Definition at line 114 of file async_queue.hpp.
|
inline |
Attempts to pop a value without blocking.
Use for draining queues or non-blocking checks. For event-driven processing, prefer pop().
Definition at line 89 of file async_queue.hpp.
|
static |
Maximum number of elements the queue can hold.
Definition at line 29 of file async_queue.hpp.