rippled
Loading...
Searching...
No Matches
TimeoutCounter.h
1#pragma once
2
3#include <xrpld/app/main/Application.h>
4
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/core/Job.h>
7
8#include <boost/asio/basic_waitable_timer.hpp>
9
10#include <mutex>
11
12namespace xrpl {
13
49{
50public:
59 virtual void
60 cancel();
61
62protected:
64
71
73 Application& app,
74 uint256 const& targetHash,
75 std::chrono::milliseconds timeoutInterval,
76 QueueJobParameter&& jobParameter,
77 beast::Journal journal);
78
79 virtual ~TimeoutCounter() = default;
80
82 void
84
86 void
88
90 virtual void
91 onTimer(bool progress, ScopedLockType&) = 0;
92
96
97 bool
98 isDone() const
99 {
100 return complete_ || failed_;
101 }
102
103 // Used in this class for access to boost::asio::io_context and
104 // xrpl::Overlay. Used in subtypes for the kitchen sink.
108
119
121
122private:
126 void
128
129 boost::asio::basic_waitable_timer<std::chrono::steady_clock> timer_;
130};
131
132} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
This class is an "active" object.
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.
beast::Journal journal_
virtual ~TimeoutCounter()=default
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.
Definition algorithm.h:5
JobType
Definition Job.h:14
std::optional< std::uint32_t > jobLimit