1#include <xrpld/app/ledger/detail/TimeoutCounter.h>
2#include <xrpld/core/JobQueue.h>
6using namespace std::chrono_literals;
21 , timerInterval_(interval)
22 , queueJobParameter_(
std::move(jobParameter))
23 , timer_(app_.getIOContext())
27 "ripple::TimeoutCounter::TimeoutCounter : interval input inside range");
37 [wptr =
pmDowncast()](boost::system::error_code
const& ec) {
38 if (ec == boost::asio::error::operation_aborted)
41 if (
auto ptr = wptr.lock())
43 ScopedLockType sl(ptr->mtx_);
59 <<
" timer due to load";
68 if (
auto sptr = wptr.lock(); sptr)
69 sptr->invokeOnTimer();
85 <<
" 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.
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::optional< std::uint32_t > jobLimit