Radix Relay
Hybrid mesh communications with Signal Protocol encryption
Loading...
Searching...
No Matches
radix_relay::core::standard_processor< Handler > Class Template Reference

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.
 

Detailed Description

template<typename Handler>
class radix_relay::core::standard_processor< Handler >

Generic queue-processing loop that HasA handler (no virtual inheritance).

Template Parameters
HandlerHandler 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:

  • in_queue_t: The type of async_queue the processor reads from
  • out_queues_t: A struct with named members for output queues

Definition at line 25 of file standard_processor.hpp.

Member Typedef Documentation

◆ in_queue_t

template<typename Handler >
using radix_relay::core::standard_processor< Handler >::in_queue_t = typename Handler::in_queue_t

Definition at line 28 of file standard_processor.hpp.

◆ out_queues_t

template<typename Handler >
using radix_relay::core::standard_processor< Handler >::out_queues_t = typename Handler::out_queues_t

Definition at line 29 of file standard_processor.hpp.

Constructor & Destructor Documentation

◆ standard_processor()

template<typename Handler >
template<typename... HandlerArgs>
radix_relay::core::standard_processor< Handler >::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 
)
inline

Constructs a standard processor with handler-specific arguments.

Template Parameters
HandlerArgsTypes of handler-specific constructor arguments
Parameters
io_contextBoost.Asio io_context for async operations
in_queueInput queue to read events from
out_queuesOutput queues struct (passed to handler constructor)
handler_argsHandler-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.

Member Function Documentation

◆ run()

template<typename Handler >
auto radix_relay::core::standard_processor< Handler >::run ( std::shared_ptr< boost::asio::cancellation_slot >  cancel_slot = nullptr) -> boost::asio::awaitable<void>
inline

Continuously processes events from the input queue until cancelled or closed.

Parameters
cancel_slotOptional cancellation slot for cancelling the async operation
Returns
Awaitable that runs until cancellation or queue closure

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().

◆ run_once()

template<typename Handler >
auto radix_relay::core::standard_processor< Handler >::run_once ( std::shared_ptr< boost::asio::cancellation_slot >  cancel_slot = nullptr) -> boost::asio::awaitable<void>
inline

Processes a single event from the input queue.

Parameters
cancel_slotOptional cancellation slot for cancelling the async operation
Returns
Awaitable that completes after processing one event

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().


The documentation for this class was generated from the following file: