RESTinio
Loading...
Searching...
No Matches
restinio::async_chain::async_handling_controller_t< Extra_Data_Factory > Class Template Referenceabstract

Interface of a controller of an async chan. More...

#include <common.hpp>

Inheritance diagram for restinio::async_chain::async_handling_controller_t< Extra_Data_Factory >:
restinio::async_chain::fixed_size_chain_t< Size, Extra_Data_Factory >::actual_controller_t restinio::async_chain::growable_size_chain_t< Extra_Data_Factory >::actual_controller_t

Public Types

using actual_request_handle_t
 Short alias for request_handle type.
using actual_async_request_scheduler_t
 Short alias for async_request_scheduler type.
using actual_on_next_result_t
 Short alias for the result type of on_next method.

Public Member Functions

virtual ~async_handling_controller_t ()=default
virtual const actual_request_handle_trequest_handle () const noexcept=0
 Get reference to the source request.

Private Member Functions

virtual actual_on_next_result_t on_next ()=0
 Command to try find a next scheduler to be invoked.

Friends

template<typename Extra_Data_Factory_For_Next>
void next (unique_async_handling_controller_t< Extra_Data_Factory_For_Next > controller)

Detailed Description

template<typename Extra_Data_Factory>
class restinio::async_chain::async_handling_controller_t< Extra_Data_Factory >

Interface of a controller of an async chan.

All actual controllers have to implement this interface.

It's assumed that implementation of that interface won't be thread safe. It means that methods like request_handle() and on_next() must not be called in parallel.

Template Parameters
Extra_Data_FactoryType of factory for creation of extra data objects for every incoming request. Should be no_extra_data_factory_t if extra data for incoming requests is not needed.
Since
v.0.7.0

Definition at line 145 of file common.hpp.

Member Typedef Documentation

◆ actual_async_request_scheduler_t

template<typename Extra_Data_Factory>
using restinio::async_chain::async_handling_controller_t< Extra_Data_Factory >::actual_async_request_scheduler_t
Initial value:
std::function< schedule_result_t(unique_async_handling_controller_t< Extra_Data_Factory >) > generic_async_request_scheduler_t
Short alias for a type of a scheduler to be used in async chains.
Definition common.hpp:93

Short alias for async_request_scheduler type.

Definition at line 158 of file common.hpp.

◆ actual_on_next_result_t

template<typename Extra_Data_Factory>
using restinio::async_chain::async_handling_controller_t< Extra_Data_Factory >::actual_on_next_result_t
Initial value:
std::variant< generic_async_request_scheduler_t< Extra_Data_Factory >, no_more_schedulers_t > on_next_result_t
Special type to be used as result of async_handling_controller's on_next method.
Definition common.hpp:119

Short alias for the result type of on_next method.

Definition at line 162 of file common.hpp.

◆ actual_request_handle_t

template<typename Extra_Data_Factory>
using restinio::async_chain::async_handling_controller_t< Extra_Data_Factory >::actual_request_handle_t
Initial value:
std::shared_ptr< generic_request_t< Extra_Data > > generic_request_handle_t
An alias for shared-pointer to incoming request.

Short alias for request_handle type.

Definition at line 154 of file common.hpp.

Constructor & Destructor Documentation

◆ ~async_handling_controller_t()

template<typename Extra_Data_Factory>
virtual restinio::async_chain::async_handling_controller_t< Extra_Data_Factory >::~async_handling_controller_t ( )
virtualdefault

Member Function Documentation

◆ on_next()

template<typename Extra_Data_Factory>
virtual actual_on_next_result_t restinio::async_chain::async_handling_controller_t< Extra_Data_Factory >::on_next ( )
nodiscardprivatepure virtual

Command to try find a next scheduler to be invoked.

Implementation of async_handling_controller_t should switch to the next scheduler in the chain and return the scheduler to be called next. If there are no such schedulers, no_more_schedulers_t must be returned.

Note
This method is intended to be called by next() function.

Implemented in restinio::async_chain::fixed_size_chain_t< Size, Extra_Data_Factory >::actual_controller_t, and restinio::async_chain::growable_size_chain_t< Extra_Data_Factory >::actual_controller_t.

◆ request_handle()

template<typename Extra_Data_Factory>
virtual const actual_request_handle_t & restinio::async_chain::async_handling_controller_t< Extra_Data_Factory >::request_handle ( ) const
nodiscardpure virtualnoexcept

Get reference to the source request.

Usage example:

{
// Get access to the source request.
const auto req = controller->request_handle();
if( restinio::http_method_get() == req->header().method() )
{
...
}
}
constexpr schedule_result_t ok() noexcept
Helper function to be used if scheduling was successful.
Definition common.hpp:49
schedule_result_t
Type for return value of a scheduler in a chain.
Definition common.hpp:25
std::unique_ptr< async_handling_controller_t< Extra_Data_Factory > > unique_async_handling_controller_t
Short alias for unique_ptr to async_handling_controller.
Definition common.hpp:84

Implemented in restinio::async_chain::fixed_size_chain_t< Size, Extra_Data_Factory >::actual_controller_t, and restinio::async_chain::growable_size_chain_t< Extra_Data_Factory >::actual_controller_t.

◆ next

template<typename Extra_Data_Factory>
template<typename Extra_Data_Factory_For_Next>
void next ( unique_async_handling_controller_t< Extra_Data_Factory_For_Next > controller)
friend

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