cpp-msgpack-rpc 0.2.0
An RPC library implementing MessagePack RPC.
Loading...
Searching...
No Matches
msgpack_rpc::clients::impl::ReconnectionTimer Class Reference

Class of timer to sleep before reconnecting. More...

#include <msgpack_rpc/clients/impl/reconnection_timer.h>

Collaboration diagram for msgpack_rpc::clients::impl::ReconnectionTimer:

Public Member Functions

 ReconnectionTimer (const std::shared_ptr< executors::IExecutor > &executor, std::shared_ptr< logging::Logger > logger, const config::ReconnectionConfig &config)
 Constructor.
template<typename Function>
void async_wait (Function &&function)
 Asynchronously wait until the next reconnection.
void cancel ()
 Cancel this timer.
void reset ()
 Reset the waiting time.

Private Member Functions

std::chrono::nanoseconds compute_waiting_time ()
 Compute the waiting time.

Private Attributes

std::chrono::nanoseconds initial_waiting_time_
 Initial waiting time.
std::uniform_int_distribution< std::chrono::nanoseconds::rep > jitter_time_dist_
 Distribution of jitter time.
std::shared_ptr< logging::Loggerlogger_
 Logger.
std::chrono::nanoseconds max_waiting_time_
 Maximum waiting time.
std::chrono::nanoseconds next_wait_time_without_jitter_
 Next waiting time without jitter.
std::mt19937 random_
 Random number generator.
executors::Timer timer_
 Timer.

Detailed Description

Class of timer to sleep before reconnecting.

Definition at line 41 of file reconnection_timer.h.

Constructor & Destructor Documentation

◆ ReconnectionTimer()

msgpack_rpc::clients::impl::ReconnectionTimer::ReconnectionTimer ( const std::shared_ptr< executors::IExecutor > & executor,
std::shared_ptr< logging::Logger > logger,
const config::ReconnectionConfig & config )
inline

Constructor.

Parameters
[in]executorExecutor.
[in]loggerLogger.
[in]configConfiguration.

Definition at line 50 of file reconnection_timer.h.

Member Function Documentation

◆ async_wait()

template<typename Function>
void msgpack_rpc::clients::impl::ReconnectionTimer::async_wait ( Function && function)
inline

Asynchronously wait until the next reconnection.

Template Parameters
FunctionType of the function called when the time elapsed.
Parameters
[in]functionFunction called when the time elapsed.

Definition at line 75 of file reconnection_timer.h.

◆ cancel()

void msgpack_rpc::clients::impl::ReconnectionTimer::cancel ( )
inline

Cancel this timer.

Definition at line 97 of file reconnection_timer.h.

◆ compute_waiting_time()

std::chrono::nanoseconds msgpack_rpc::clients::impl::ReconnectionTimer::compute_waiting_time ( )
inlinenodiscardprivate

Compute the waiting time.

Returns
Waiting time.

Definition at line 105 of file reconnection_timer.h.

◆ reset()

void msgpack_rpc::clients::impl::ReconnectionTimer::reset ( )
inline

Reset the waiting time.

Note
Call this function if a connection is established successfully once.

Definition at line 92 of file reconnection_timer.h.

Member Data Documentation

◆ initial_waiting_time_

std::chrono::nanoseconds msgpack_rpc::clients::impl::ReconnectionTimer::initial_waiting_time_
private

Initial waiting time.

Definition at line 124 of file reconnection_timer.h.

◆ jitter_time_dist_

std::uniform_int_distribution<std::chrono::nanoseconds::rep> msgpack_rpc::clients::impl::ReconnectionTimer::jitter_time_dist_
private

Distribution of jitter time.

Definition at line 134 of file reconnection_timer.h.

◆ logger_

std::shared_ptr<logging::Logger> msgpack_rpc::clients::impl::ReconnectionTimer::logger_
private

Logger.

Definition at line 121 of file reconnection_timer.h.

◆ max_waiting_time_

std::chrono::nanoseconds msgpack_rpc::clients::impl::ReconnectionTimer::max_waiting_time_
private

Maximum waiting time.

Definition at line 127 of file reconnection_timer.h.

◆ next_wait_time_without_jitter_

std::chrono::nanoseconds msgpack_rpc::clients::impl::ReconnectionTimer::next_wait_time_without_jitter_
private

Next waiting time without jitter.

Definition at line 137 of file reconnection_timer.h.

◆ random_

std::mt19937 msgpack_rpc::clients::impl::ReconnectionTimer::random_
private

Random number generator.

Definition at line 130 of file reconnection_timer.h.

◆ timer_

executors::Timer msgpack_rpc::clients::impl::ReconnectionTimer::timer_
private

Timer.

Definition at line 118 of file reconnection_timer.h.


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