11 #include <restinio/asio_include.hpp> 12 #include <restinio/compiler_features.hpp> 14 #include <so_5/all.hpp> 22 #if defined(SO_5_VERSION) 23 #if SO_5_VERSION < SO_5_VERSION_MAKE(6ull
, 0ull
, 0ull
) 24 #define RESTINIO_USE_SO_5_5 27 #define RESTINIO_USE_SO_5_5 35 struct msg_check_timer_t
final :
public so_5::message_t
54 class so_timer_manager_t
final 58 so_5::environment_t & env,
60 std::chrono::steady_clock::duration check_period )
67 class timer_guard_t
final 71 so_5::environment_t & env,
73 std::chrono::steady_clock::duration check_period )
81 schedule( tcp_connection_ctx_weak_handle_t weak_handle )
83 if( !m_current_op_timer.is_active() )
85 m_current_op_timer = so_5::send_periodic< msg_check_timer_t >(
90 std::move(weak_handle) );
103 RESTINIO_ENSURE_NOEXCEPT_CALL( m_current_op_timer.release() );
119 return timer_guard_t{ m_env, m_mbox, m_check_period };
135 so_5::environment_t & env,
137 std::chrono::steady_clock::duration check_period =
std::
chrono::
seconds{ 1 } )
146 return std::make_shared< so_timer_manager_t >( m_env, m_mbox, m_check_period );
227 void start()
const noexcept {}
228 void stop()
const noexcept {}
269 class a_timeout_handler_t
final 270 :
public so_5::agent_t
280 [](
const msg_check_timer_t & msg ){
281 if(
auto h = msg.m_weak_handle.lock() )
282 h->check_timeout( h );
timer_guard_t(so_5::environment_t &env, so_5::mbox_t mbox, std::chrono::steady_clock::duration check_period)
so_5::environment_t & m_env
tcp_connection_ctx_weak_handle_t m_weak_handle
#define RESTINIO_USE_SO_5_5
const std::chrono::steady_clock::duration m_check_period
void cancel() noexcept
Cancel timeout guard if any.
const std::chrono::steady_clock::duration m_check_period
so_5::environment_t & m_env
so_timer_manager_t(so_5::environment_t &env, so_5::mbox_t mbox, std::chrono::steady_clock::duration check_period)
so_5::environment_t & m_env
a_timeout_handler_t(context_t ctx)
so_5::agent_t so_base_type_t
const so_5::mbox_t m_mbox
timer_guard_t create_timer_guard()
void schedule(tcp_connection_ctx_weak_handle_t weak_handle)
Schedule timeout check invocation.
void stop() const noexcept
void start() const noexcept
Start/stop timer manager.
auto create(asio_ns::io_context &) const
const std::chrono::steady_clock::duration m_check_period
msg_check_timer_t(tcp_connection_ctx_weak_handle_t weak_handle)
so_5::timer_id_t m_current_op_timer
factory_t(so_5::environment_t &env, so_5::mbox_t mbox, std::chrono::steady_clock::duration check_period=std::chrono::seconds{ 1 })
std::enable_if< std::is_same< Parameter_Container, query_string_params_t >::value||std::is_same< Parameter_Container, router::route_params_t >::value, optional_t< Value_Type > >::type opt_value(const Parameter_Container ¶ms, string_view_t key)
Gets the value of a parameter specified by key wrapped in optional_t<Value_Type> if parameter exists ...