rippled
Loading...
Searching...
No Matches
TimeoutCounter.h
1#ifndef XRPL_APP_LEDGER_TIMEOUTCOUNTER_H_INCLUDED
2#define XRPL_APP_LEDGER_TIMEOUTCOUNTER_H_INCLUDED
3
4#include <xrpld/app/main/Application.h>
5#include <xrpld/core/Job.h>
6
7#include <xrpl/beast/utility/Journal.h>
8
9#include <boost/asio/basic_waitable_timer.hpp>
10
11#include <mutex>
12
13namespace ripple {
14
50{
51public:
60 virtual void
61 cancel();
62
63protected:
65
72
74 Application& app,
75 uint256 const& targetHash,
76 std::chrono::milliseconds timeoutInterval,
77 QueueJobParameter&& jobParameter,
78 beast::Journal journal);
79
80 virtual ~TimeoutCounter() = default;
81
83 void
85
87 void
89
91 virtual void
92 onTimer(bool progress, ScopedLockType&) = 0;
93
97
98 bool
99 isDone() const
100 {
101 return complete_ || failed_;
102 }
103
104 // Used in this class for access to boost::asio::io_context and
105 // ripple::Overlay. Used in subtypes for the kitchen sink.
109
120
122
123private:
127 void
129
130 boost::asio::basic_waitable_timer<std::chrono::steady_clock> timer_;
131};
132
133} // namespace ripple
134
135#endif
A generic endpoint for log messages.
Definition Journal.h:41
This class is an "active" object.
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().
virtual ~TimeoutCounter()=default
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.
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.
Definition algorithm.h:6
JobType
Definition Job.h:16
std::optional< std::uint32_t > jobLimit