1#include <xrpld/app/ledger/detail/TimeoutCounter.h>
3#include <xrpld/app/main/Application.h>
5#include <xrpl/basics/Log.h>
6#include <xrpl/basics/base_uint.h>
7#include <xrpl/beast/utility/Journal.h>
8#include <xrpl/beast/utility/instrumentation.h>
9#include <xrpl/core/JobQueue.h>
11#include <boost/asio/error.hpp>
12#include <boost/system/detail/error_code.hpp>
19using namespace std::chrono_literals;
36 "xrpl::TimeoutCounter::TimeoutCounter : interval input inside range");
45 timer_.async_wait([wptr =
pmDowncast()](boost::system::error_code
const& ec) {
46 if (ec == boost::asio::error::operation_aborted)
49 if (
auto ptr = wptr.lock())
67 <<
" timer due to load";
72 app_.getJobQueue().addJob(
74 if (
auto sptr = wptr.lock(); sptr)
75 sptr->invokeOnTimer();
91 <<
" acquiring " <<
hash_;
A generic endpoint for log messages.
TimeoutCounter(Application &app, uint256 const &targetHash, std::chrono::milliseconds timeoutInterval, QueueJobParameter &&jobParameter, beast::Journal journal)
boost::asio::basic_waitable_timer< std::chrono::steady_clock > timer_
std::recursive_mutex mtx_
virtual std::weak_ptr< TimeoutCounter > pmDowncast()=0
Return a weak pointer to this.
virtual void onTimer(bool progress, ScopedLockType &)=0
Hook called from invokeOnTimer().
std::unique_lock< std::recursive_mutex > ScopedLockType
uint256 const hash_
The hash of the object (in practice, always a ledger) we are trying to fetch.
void queueJob(ScopedLockType &)
Queue a job to call invokeOnTimer().
bool progress_
Whether forward progress has been made.
QueueJobParameter queueJobParameter_
void invokeOnTimer()
Calls onTimer() if in the right state.
void setTimer(ScopedLockType &)
Schedule a call to queueJob() after timerInterval_.
std::chrono::milliseconds timerInterval_
The minimum time to wait between calls to execute().
virtual void cancel()
Cancel the task by marking it as failed if the task is not done.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.