Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
cluster::impl::FallbackRecoveryTimer Class Reference

One-shot timer for fallback recovery, with internal thread-safety. More...

#include <FallbackRecoveryTimer.hpp>

Public Member Functions

 FallbackRecoveryTimer (boost::asio::thread_pool &ctx, std::chrono::steady_clock::duration recoveryTime)
 Construct a timer bound to the given thread pool.
bool isRunning () const
 Returns true if an async_wait is currently pending.
template<typename Callback>
void start (Callback &&callback)
 Arm the timer and schedule callback for when it fires.
void cancel ()
 Cancel any pending async_wait and clear the running flag.

Detailed Description

One-shot timer for fallback recovery, with internal thread-safety.

The timer state — including the boost::asio::steady_timer, the running flag, and the recovery duration — is held inside a mutex-protected Impl struct referenced via shared_ptr. This makes FallbackRecoveryTimer cheap to copy: all copies share the same underlying state. All public methods are thread-safe; callers do not need an external util::Mutex.

Constructor & Destructor Documentation

◆ FallbackRecoveryTimer()

cluster::impl::FallbackRecoveryTimer::FallbackRecoveryTimer ( boost::asio::thread_pool & ctx,
std::chrono::steady_clock::duration recoveryTime )

Construct a timer bound to the given thread pool.

Parameters
ctxThread pool whose executor the timer is posted to.
recoveryTimeDuration to wait before the timer fires.

Member Function Documentation

◆ start()

template<typename Callback>
void cluster::impl::FallbackRecoveryTimer::start ( Callback && callback)
inline

Arm the timer and schedule callback for when it fires.

Sets the running flag, calls expires_after, and posts async_wait. The internal async_wait handler clears the running flag before forwarding the error_code to callback. If the timer is cancelled, callback receives boost::asio::error::operation_aborted — callers must handle this.

Parameters
callbackInvoked with the error code when the timer fires or is cancelled.

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