1#include <test/csf/Scheduler.h> 
    3#include <xrpl/beast/unit_test.h> 
   16        using namespace std::chrono_literals;
 
   20        scheduler.
in(1s, [&] { seen.
insert(1); });
 
   21        scheduler.
in(2s, [&] { seen.
insert(2); });
 
   22        auto token = scheduler.
in(3s, [&] { seen.
insert(3); });
 
   23        scheduler.
at(scheduler.
now() + 4s, [&] { seen.insert(4); });
 
   24        scheduler.
at(scheduler.
now() + 8s, [&] { seen.insert(8); });
 
   26        auto start = scheduler.
now();
 
   29        BEAST_EXPECT(seen.
empty());
 
   32        BEAST_EXPECT(scheduler.
now() == (start + 1s));
 
   37        BEAST_EXPECT(scheduler.
now() == (start + 1s));
 
   40        BEAST_EXPECT(scheduler.
step_for(1s));
 
   42        BEAST_EXPECT(scheduler.
now() == (start + 2s));
 
   46        BEAST_EXPECT(scheduler.
step_for(1s));
 
   48        BEAST_EXPECT(scheduler.
now() == (start + 3s));
 
   51        BEAST_EXPECT(scheduler.
step_while([&]() { return seen.size() < 3; }));
 
   53        BEAST_EXPECT(scheduler.
now() == (start + 4s));
 
   56        BEAST_EXPECT(scheduler.
step());
 
   58        BEAST_EXPECT(scheduler.
now() == (start + 8s));
 
   61        BEAST_EXPECT(!scheduler.
step());
 
   63        BEAST_EXPECT(scheduler.
now() == (start + 8s));
 
 
 
   67BEAST_DEFINE_TESTSUITE(Scheduler, csf, 
ripple);
 
void run() override
Runs the suite.
 
Simulated discrete-event scheduler.
 
bool step_one()
Run the scheduler for up to one event.
 
bool step_while(Function &&func)
Run the scheduler while a condition is true.
 
cancel_token at(time_point const &when, Function &&f)
Schedule an event at a specific time.
 
bool step_for(std::chrono::duration< Period, Rep > const &amount)
Run the scheduler until time has elapsed.
 
time_point now() const
Return the current network time.
 
bool step_until(time_point const &until)
Run the scheduler until the specified time.
 
void cancel(cancel_token const &token)
Cancel a timer.
 
bool step()
Run the scheduler until no events remain.
 
cancel_token in(duration const &delay, Function &&f)
Schedule an event after a specified duration passes.
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.