|
Clio
develop
The XRP Ledger API server.
|
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. | |
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.
| cluster::impl::FallbackRecoveryTimer::FallbackRecoveryTimer | ( | boost::asio::thread_pool & | ctx, |
| std::chrono::steady_clock::duration | recoveryTime ) |
Construct a timer bound to the given thread pool.
| ctx | Thread pool whose executor the timer is posted to. |
| recoveryTime | Duration to wait before the timer fires. |
|
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.
| callback | Invoked with the error code when the timer fires or is cancelled. |