3#include <xrpl/basics/ByteUtilities.h>
4#include <xrpl/beast/clock/manual_clock.h>
6#include <boost/container/pmr/monotonic_buffer_resource.hpp>
7#include <boost/intrusive/set.hpp>
38 boost::intrusive::set_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>>;
65 template <
class Handler>
76 template <
class DeducedHandler>
93 make_multiset<Event, boost::intrusive::constant_time_size<false>>::type;
95 boost::container::pmr::monotonic_buffer_resource*
alloc_;
105 explicit QueueType(boost::container::pmr::monotonic_buffer_resource* alloc);
118 template <
class Handler>
119 by_when_set::iterator
165 template <
class Function>
178 template <
class Function>
233 template <
class Function>
260 template <
class Period,
class Rep>
279 alloc_->deallocate(e,
sizeof(e));
301template <
class Handler>
306 auto const p =
alloc_->allocate(
sizeof(event_type));
315 auto next =
byWhen_.erase(iter);
317 alloc_->deallocate(&e,
sizeof(e));
357template <
class Function>
364template <
class Function>
382 auto const iter =
queue_.begin();
402template <
class Function>
421 auto iter =
queue_.begin();
422 if (iter->when > until)
431 }
while (iter !=
queue_.end() && iter->when <= until);
433 return iter !=
queue_.end();
436template <
class Period,
class Rep>
std::chrono::steady_clock::duration duration
std::chrono::steady_clock::time_point time_point
Manual clock implementation.
EventImpl(time_point when, DeducedHandler &&h)
void operator()() const override
EventImpl(EventImpl const &)=delete
EventImpl & operator=(EventImpl const &)=delete
iterator erase(iterator iter)
QueueType & operator=(QueueType const &)=delete
boost::container::pmr::monotonic_buffer_resource * alloc_
by_when_set::iterator emplace(time_point when, Handler &&h)
boost::intrusive:: make_multiset< Event, boost::intrusive::constant_time_size< false > >::type by_when_set
QueueType(QueueType const &)=delete
by_when_set::iterator iterator
clock_type & clock() const
Return the clock.
clock_type::time_point time_point
beast::ManualClock< std::chrono::steady_clock > clock_type
bool step()
Run the scheduler until no events remain.
CancelToken at(time_point const &when, Function &&f)
Schedule an event at a specific time.
boost::intrusive::set_base_hook< boost::intrusive::link_mode< boost::intrusive::normal_link > > by_when_hook
time_point now() const
Return the current network time.
bool stepUntil(time_point const &until)
Run the scheduler until the specified time.
void cancel(CancelToken const &token)
Cancel a timer.
CancelToken in(duration const &delay, Function &&f)
Schedule an event after a specified duration passes.
bool stepOne()
Run the scheduler for up to one event.
Scheduler & operator=(Scheduler const &)=delete
boost::container::pmr::monotonic_buffer_resource alloc_
clock_type::duration duration
bool stepWhile(Function &&func)
Run the scheduler while a condition is true.
Scheduler(Scheduler const &)=delete
bool stepFor(std::chrono::duration< Period, Rep > const &amount)
Run the scheduler until time has elapsed.
constexpr auto kilobytes(T value) noexcept
CancelToken(CancelToken const &)=default
CancelToken(QueueType::iterator iter)
QueueType::iterator iter_
CancelToken & operator=(CancelToken const &)=default
Event & operator=(Event const &)=delete
bool operator<(Event const &other) const
virtual void operator()() const =0
Event(Event const &)=delete