22 #ifndef NDN_CXX_UTIL_SCHEDULER_HPP
23 #define NDN_CXX_UTIL_SCHEDULER_HPP
30 #include <boost/operators.hpp>
31 #include <boost/system/error_code.hpp>
75 operator
bool() const noexcept;
99 return (!lhs && !rhs) ||
100 (!lhs.m_info.owner_before(rhs.m_info) &&
101 !rhs.m_info.owner_before(lhs.m_info));
107 return os << eventId.m_info.lock();
111 weak_ptr<EventInfo> m_info;
141 Scheduler(boost::asio::io_context& ioCtx);
160 cancelImpl(
const shared_ptr<EventInfo>&
info);
173 executeEvent(
const boost::system::error_code& code);
176 class EventQueueCompare
180 operator()(
const shared_ptr<EventInfo>& a,
const shared_ptr<EventInfo>& b)
const noexcept;
183 using EventQueue = std::multiset<shared_ptr<EventInfo>, EventQueueCompare>;
186 unique_ptr<detail::SteadyTimer> m_timer;
187 bool m_isEventExecuting =
false;
195 using scheduler::Scheduler;
Handle to cancel an operation.
A handle for a scheduled event.
friend std::ostream & operator<<(std::ostream &os, const EventId &eventId)
void reset() noexcept
Clear this EventId without canceling the associated event.
EventId() noexcept=default
Constructs an empty EventId.
Generic time-based event scheduler.
void cancelAllEvents()
Cancel all scheduled events.
Scheduler(boost::asio::io_context &ioCtx)
EventId schedule(time::nanoseconds after, EventCallback callback)
Schedule a one-time event after the specified delay.
Common includes and macros used throughout the library.
std::function< void()> EventCallback
Function to be invoked when a scheduled event expires.
::boost::chrono::nanoseconds nanoseconds