|
xrpld
|
This class is an "active" object. More...
#include <TimeoutCounter.h>


Classes | |
| struct | QueueJobParameter |
Public Member Functions | |
| virtual void | cancel () |
| Cancel the task by marking it as failed if the task is not done. | |
| virtual | ~TimeoutCounter ()=default |
Protected Types | |
| using | ScopedLockType = std::unique_lock<std::recursive_mutex> |
Protected Member Functions | |
| TimeoutCounter (Application &app, uint256 const &targetHash, std::chrono::milliseconds timeoutInterval, QueueJobParameter &&jobParameter, beast::Journal journal) | |
| void | setTimer (ScopedLockType &) |
| Schedule a call to queueJob() after timerInterval_. | |
| void | queueJob (ScopedLockType &) |
| Queue a job to call invokeOnTimer(). | |
| virtual void | onTimer (bool progress, ScopedLockType &)=0 |
| Hook called from invokeOnTimer(). | |
| virtual std::weak_ptr< TimeoutCounter > | pmDowncast ()=0 |
| Return a weak pointer to this. | |
| bool | isDone () const |
Protected Attributes | |
| Application & | app_ |
| beast::Journal | journal_ |
| std::recursive_mutex | mtx_ |
| uint256 const | hash_ |
| The hash of the object (in practice, always a ledger) we are trying to fetch. | |
| int | timeouts_ {0} |
| bool | complete_ {false} |
| bool | failed_ {false} |
| bool | progress_ {false} |
| Whether forward progress has been made. | |
| std::chrono::milliseconds | timerInterval_ |
| The minimum time to wait between calls to execute(). | |
| QueueJobParameter | queueJobParameter_ |
Private Member Functions | |
| void | invokeOnTimer () |
| Calls onTimer() if in the right state. | |
Private Attributes | |
| boost::asio::basic_waitable_timer< std::chrono::steady_clock > | timer_ |
This class is an "active" object.
It maintains its own timer and dispatches work to a job queue. Implementations derive from this class and override the abstract hook functions in the base.
This class implements an asynchronous loop:
This loop executes concurrently with another asynchronous sequence, implemented by the subtype, that is trying to make progress and eventually set complete_ = true. While it is making progress but not complete, it should set progress_ = true, which is passed to onTimer so it can decide whether to postpone failure and reset the timeout. However, if it can complete all its work in one synchronous step (while it holds the lock), then it can ignore progress_.
Definition at line 48 of file TimeoutCounter.h.
|
protected |
Definition at line 65 of file TimeoutCounter.h.
|
virtualdefault |
|
protected |
Definition at line 21 of file TimeoutCounter.cpp.
|
virtual |
Cancel the task by marking it as failed if the task is not done.
Definition at line 105 of file TimeoutCounter.cpp.
|
protected |
Schedule a call to queueJob() after timerInterval_.
Definition at line 40 of file TimeoutCounter.cpp.
|
protected |
Queue a job to call invokeOnTimer().
Definition at line 58 of file TimeoutCounter.cpp.
|
protectedpure virtual |
Hook called from invokeOnTimer().
Implemented in xrpl::InboundLedger, xrpl::LedgerDeltaAcquire, xrpl::LedgerReplayTask, xrpl::SkipListAcquire, and xrpl::TransactionAcquire.
|
protectedpure virtual |
Return a weak pointer to this.
Implemented in xrpl::InboundLedger, xrpl::LedgerDeltaAcquire, xrpl::LedgerReplayTask, xrpl::SkipListAcquire, and xrpl::TransactionAcquire.
|
protected |
Definition at line 98 of file TimeoutCounter.h.
|
private |
Calls onTimer() if in the right state.
Only called by queueJob().
Definition at line 80 of file TimeoutCounter.cpp.
|
protected |
Definition at line 105 of file TimeoutCounter.h.
|
protected |
Definition at line 106 of file TimeoutCounter.h.
|
mutableprotected |
Definition at line 107 of file TimeoutCounter.h.
|
protected |
The hash of the object (in practice, always a ledger) we are trying to fetch.
Definition at line 111 of file TimeoutCounter.h.
|
protected |
Definition at line 112 of file TimeoutCounter.h.
|
protected |
Definition at line 113 of file TimeoutCounter.h.
|
protected |
Definition at line 114 of file TimeoutCounter.h.
|
protected |
Whether forward progress has been made.
Definition at line 116 of file TimeoutCounter.h.
|
protected |
The minimum time to wait between calls to execute().
Definition at line 118 of file TimeoutCounter.h.
|
protected |
Definition at line 120 of file TimeoutCounter.h.
|
private |
Definition at line 129 of file TimeoutCounter.h.