|
Radix Relay
Hybrid mesh communications with Signal Protocol encryption
|
Generic queue-processing loop that HasA handler (no virtual inheritance). More...
#include <standard_processor.hpp>
Public Types | |
| using | in_queue_t = typename Handler::in_queue_t |
| using | out_queues_t = typename Handler::out_queues_t |
Public Member Functions | |
| template<typename... HandlerArgs> | |
| standard_processor (const std::shared_ptr< boost::asio::io_context > &io_context, const std::shared_ptr< in_queue_t > &in_queue, const out_queues_t &out_queues, HandlerArgs &&...handler_args) | |
| Constructs a standard processor with handler-specific arguments. | |
| auto | run_once (std::shared_ptr< boost::asio::cancellation_slot > cancel_slot=nullptr) -> boost::asio::awaitable< void > |
| Processes a single event from the input queue. | |
| auto | run (std::shared_ptr< boost::asio::cancellation_slot > cancel_slot=nullptr) -> boost::asio::awaitable< void > |
| Continuously processes events from the input queue until cancelled or closed. | |
Generic queue-processing loop that HasA handler (no virtual inheritance).
| Handler | Handler type that provides in_queue_t and out_queues_t type traits |
Standard processor eliminates code duplication across different processor types by providing a single implementation of the async run loop with error handling. The handler specifies its queue dependencies via type traits:
Definition at line 25 of file standard_processor.hpp.
| using radix_relay::core::standard_processor< Handler >::in_queue_t = typename Handler::in_queue_t |
Definition at line 28 of file standard_processor.hpp.
| using radix_relay::core::standard_processor< Handler >::out_queues_t = typename Handler::out_queues_t |
Definition at line 29 of file standard_processor.hpp.
|
inline |
Constructs a standard processor with handler-specific arguments.
| HandlerArgs | Types of handler-specific constructor arguments |
| io_context | Boost.Asio io_context for async operations |
| in_queue | Input queue to read events from |
| out_queues | Output queues struct (passed to handler constructor) |
| handler_args | Handler-specific arguments forwarded to handler constructor |
The constructor creates the handler by forwarding handler_args followed by out_queues to the Handler constructor. This supports handlers with varying constructor signatures.
Definition at line 44 of file standard_processor.hpp.
|
inline |
Continuously processes events from the input queue until cancelled or closed.
| cancel_slot | Optional cancellation slot for cancelling the async operation |
Implements the standard async run loop with error handling. Continuously pops events and dispatches them to the handler. Handles expected errors (cancellation, channel closure) gracefully while propagating unexpected errors.
Definition at line 78 of file standard_processor.hpp.
References radix_relay::core::standard_processor< Handler >::run_once().
|
inline |
Processes a single event from the input queue.
| cancel_slot | Optional cancellation slot for cancelling the async operation |
Pops one event from the input queue, passes it to the handler's handle() method, and returns. This is useful for controlled event processing and testing.
Definition at line 61 of file standard_processor.hpp.
Referenced by radix_relay::core::standard_processor< Handler >::run().