|
xrpld
|
Simulated discrete-event scheduler. More...
#include <Scheduler.h>

Classes | |
| struct | Event |
| class | EventImpl |
| class | QueueType |
| struct | CancelToken |
Public Types | |
| using | clock_type = beast::ManualClock<std::chrono::steady_clock> |
| using | duration = clock_type::duration |
| using | time_point = clock_type::time_point |
Public Member Functions | |
| Scheduler (Scheduler const &)=delete | |
| Scheduler & | operator= (Scheduler const &)=delete |
| Scheduler () | |
| clock_type & | clock () const |
| Return the clock. | |
| time_point | now () const |
| Return the current network time. | |
| template<class Function> | |
| CancelToken | at (time_point const &when, Function &&f) |
| Schedule an event at a specific time. | |
| template<class Function> | |
| CancelToken | in (duration const &delay, Function &&f) |
| Schedule an event after a specified duration passes. | |
| void | cancel (CancelToken const &token) |
| Cancel a timer. | |
| bool | stepOne () |
| Run the scheduler for up to one event. | |
| bool | step () |
| Run the scheduler until no events remain. | |
| template<class Function> | |
| bool | stepWhile (Function &&func) |
| Run the scheduler while a condition is true. | |
| bool | stepUntil (time_point const &until) |
| Run the scheduler until the specified time. | |
| template<class Period, class Rep> | |
| bool | stepFor (std::chrono::duration< Period, Rep > const &amount) |
| Run the scheduler until time has elapsed. | |
Private Types | |
| using | by_when_hook |
Private Attributes | |
| boost::container::pmr::monotonic_buffer_resource | alloc_ {kilobytes(256)} |
| QueueType | queue_ |
| clock_type | clock_ |
Simulated discrete-event scheduler.
Simulates the behavior of events using a single common clock.
An event is modeled using a lambda function and is scheduled to occur at a specific time. Events may be canceled using a token returned when the event is scheduled.
The caller uses one or more of the step, stepOne, stepFor, stepUntil and stepWhile functions to process scheduled events.
Definition at line 27 of file src/tests/libxrpl/csf/Scheduler.h.
Definition at line 30 of file src/tests/libxrpl/csf/Scheduler.h.
Definition at line 32 of file src/tests/libxrpl/csf/Scheduler.h.
Definition at line 34 of file src/tests/libxrpl/csf/Scheduler.h.
|
private |
Definition at line 37 of file src/tests/libxrpl/csf/Scheduler.h.
|
delete |
| xrpl::test::csf::Scheduler::Scheduler | ( | ) |
Definition at line 341 of file src/tests/libxrpl/csf/Scheduler.h.
| auto xrpl::test::csf::Scheduler::clock | ( | ) | const |
Return the clock.
(aged_containers want a non-const ref =(
Definition at line 346 of file src/tests/libxrpl/csf/Scheduler.h.
| auto xrpl::test::csf::Scheduler::now | ( | ) | const |
Return the current network time.
Definition at line 352 of file src/tests/libxrpl/csf/Scheduler.h.
| auto xrpl::test::csf::Scheduler::at | ( | time_point const & | when, |
| Function && | f ) -> CancelToken |
Schedule an event at a specific time.
Effects:
When the network time is reached, the function will be called with no arguments.
Definition at line 359 of file src/tests/libxrpl/csf/Scheduler.h.
| auto xrpl::test::csf::Scheduler::in | ( | duration const & | delay, |
| Function && | f ) -> CancelToken |
Schedule an event after a specified duration passes.
Effects:
When the specified time has elapsed, the function will be called with no arguments.
Definition at line 366 of file src/tests/libxrpl/csf/Scheduler.h.
| void xrpl::test::csf::Scheduler::cancel | ( | CancelToken const & | token | ) |
Cancel a timer.
Preconditions:
`token` was the return value of a call timer() which has not yet been invoked.
Definition at line 372 of file src/tests/libxrpl/csf/Scheduler.h.
| bool xrpl::test::csf::Scheduler::stepOne | ( | ) |
Run the scheduler for up to one event.
Effects:
The clock is advanced to the time of the last delivered event.
Definition at line 378 of file src/tests/libxrpl/csf/Scheduler.h.
| bool xrpl::test::csf::Scheduler::step | ( | ) |
Run the scheduler until no events remain.
Effects:
The clock is advanced to the time of the last event.
Definition at line 390 of file src/tests/libxrpl/csf/Scheduler.h.
| bool xrpl::test::csf::Scheduler::stepWhile | ( | Function && | func | ) |
Run the scheduler while a condition is true.
Function takes no arguments and will be called repeatedly after each event is processed to decide whether to continue.
Effects:
The clock is advanced to the time of the last delivered event.
Definition at line 404 of file src/tests/libxrpl/csf/Scheduler.h.
| bool xrpl::test::csf::Scheduler::stepUntil | ( | time_point const & | until | ) |
Run the scheduler until the specified time.
Effects:
The clock is advanced to the specified time.
Definition at line 413 of file src/tests/libxrpl/csf/Scheduler.h.
| bool xrpl::test::csf::Scheduler::stepFor | ( | std::chrono::duration< Period, Rep > const & | amount | ) |
Run the scheduler until time has elapsed.
Effects:
The clock is advanced by the specified duration.
Definition at line 438 of file src/tests/libxrpl/csf/Scheduler.h.
|
private |
Definition at line 126 of file src/tests/libxrpl/csf/Scheduler.h.
|
private |
Definition at line 127 of file src/tests/libxrpl/csf/Scheduler.h.
|
mutableprivate |
Definition at line 130 of file src/tests/libxrpl/csf/Scheduler.h.