20#include <xrpld/app/ledger/detail/TimeoutCounter.h>
21#include <xrpld/app/main/Application.h>
22#include <xrpld/core/JobQueue.h>
23#include <xrpld/overlay/Overlay.h>
27using namespace std::chrono_literals;
43 , timerInterval_(interval)
44 , queueJobParameter_(
std::move(jobParameter))
45 , timer_(app_.getIOService())
49 "ripple::TimeoutCounter::TimeoutCounter : interval input inside range");
61 [wptr =
pmDowncast()](boost::system::error_code
const& ec) {
62 if (ec == boost::asio::error::operation_aborted)
65 if (
auto ptr = wptr.lock())
67 JLOG(ptr->journal_.debug())
68 <<
"timer: ec: " << ec <<
" (operation_aborted: "
69 << boost::asio::error::operation_aborted <<
" - "
70 << (ec == boost::asio::error::operation_aborted ?
"aborted"
73 ScopedLockType sl(ptr->mtx_);
89 <<
" timer due to load";
98 if (
auto sptr = wptr.lock(); sptr)
99 sptr->invokeOnTimer();
A generic endpoint for log messages.
virtual JobQueue & getJobQueue()=0
int getJobCountTotal(JobType t) const
Jobs waiting plus running at this priority.
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
void queueJob(ScopedLockType &)
Queue a job to call invokeOnTimer().
virtual void onTimer(bool progress, ScopedLockType &)=0
Hook called from invokeOnTimer().
bool progress_
Whether forward progress has been made.
void setTimer(ScopedLockType &)
Schedule a call to queueJob() after mTimerInterval.
void invokeOnTimer()
Calls onTimer() if in the right state.
std::chrono::milliseconds timerInterval_
The minimum time to wait between calls to execute().
QueueJobParameter queueJobParameter_
uint256 const hash_
The hash of the object (in practice, always a ledger) we are trying to fetch.
boost::asio::basic_waitable_timer< std::chrono::steady_clock > timer_
virtual std::weak_ptr< TimeoutCounter > pmDowncast()=0
Return a weak pointer to this.
TimeoutCounter(Application &app, uint256 const &targetHash, std::chrono::milliseconds timeoutInterval, QueueJobParameter &&jobParameter, beast::Journal journal)
virtual void cancel()
Cancel the task by marking it as failed if the task is not done.
std::recursive_mutex mtx_
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string to_short_string(base_uint< Bits, Tag > const &a)
std::optional< std::uint32_t > jobLimit