2
3
6
7
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
35struct msg_check_timer_t
final :
public so_5::message_t
54class 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) );
97
98
99
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 );
201
202
203
227 void start()
const noexcept {}
228 void stop()
const noexcept {}
269class 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 );
so_5::agent_t so_base_type_t
a_timeout_handler_t(context_t ctx)
const std::chrono::steady_clock::duration m_check_period
timer_guard_t(so_5::environment_t &env, so_5::mbox_t mbox, std::chrono::steady_clock::duration check_period)
void schedule(tcp_connection_ctx_weak_handle_t weak_handle)
Schedule timeout check invocation.
void cancel() noexcept
Cancel timeout guard if any.
const so_5::mbox_t m_mbox
so_5::timer_id_t m_current_op_timer
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)
timer_guard_t create_timer_guard()
so_5::environment_t & m_env
const std::chrono::steady_clock::duration m_check_period
void start() const noexcept
Start/stop timer manager.
void stop() const noexcept
#define RESTINIO_ENSURE_NOEXCEPT_CALL(expr)
A wrapper around static_assert for checking that an expression is noexcept and execution of that expr...
#define RESTINIO_USE_SO_5_5
tcp_connection_ctx_weak_handle_t m_weak_handle
msg_check_timer_t(tcp_connection_ctx_weak_handle_t weak_handle)
const std::chrono::steady_clock::duration m_check_period
factory_t(so_5::environment_t &env, so_5::mbox_t mbox, std::chrono::steady_clock::duration check_period=std::chrono::seconds{ 1 })
so_5::environment_t & m_env
auto create(asio_ns::io_context &) const