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>
36 boost::intrusive::set_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>>;
63 template <
class Handler>
74 template <
class DeducedHandler>
91 make_multiset<Event, boost::intrusive::constant_time_size<false>>::type;
93 boost::container::pmr::monotonic_buffer_resource*
alloc_;
103 explicit QueueType(boost::container::pmr::monotonic_buffer_resource* alloc);
116 template <
class Handler>
117 by_when_set::iterator
159 template <
class Function>
171 template <
class Function>
222 template <
class Function>
247 template <
class Period,
class Rep>
266 alloc_->deallocate(e,
sizeof(e));
288template <
class Handler>
293 auto const p =
alloc_->allocate(
sizeof(event_type));
302 auto next =
byWhen_.erase(iter);
304 alloc_->deallocate(&e,
sizeof(e));
344template <
class Function>
351template <
class Function>
369 auto const iter =
queue_.begin();
389template <
class Function>
408 auto iter =
queue_.begin();
409 if (iter->when > until)
418 }
while (iter !=
queue_.end() && iter->when <= until);
420 return iter !=
queue_.end();
423template <
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