1#include <xrpld/app/ledger/detail/TimeoutCounter.h>
3#include <xrpl/core/JobQueue.h>
7using namespace std::chrono_literals;
22 , timerInterval_(interval)
23 , queueJobParameter_(
std::move(jobParameter))
24 , timer_(app_.getIOContext())
28 "xrpl::TimeoutCounter::TimeoutCounter : interval input inside range");
38 [wptr =
pmDowncast()](boost::system::error_code
const& ec) {
39 if (ec == boost::asio::error::operation_aborted)
42 if (
auto ptr = wptr.lock())
44 ScopedLockType sl(ptr->mtx_);
60 <<
" timer due to load";
69 if (
auto sptr = wptr.lock(); sptr)
70 sptr->invokeOnTimer();
86 <<
" acquiring " <<
hash_;
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.
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().
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 mTimerInterval.
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.
std::optional< std::uint32_t > jobLimit