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