22 #ifndef NDN_CXX_UTIL_SCHEDULER_HPP
23 #define NDN_CXX_UTIL_SCHEDULER_HPP
29 #include <boost/system/error_code.hpp>
72 operator
bool() const noexcept;
90 return (!lhs && !rhs) ||
91 (!lhs.m_info.owner_before(rhs.m_info) &&
92 !rhs.m_info.owner_before(lhs.m_info));
105 weak_ptr<EventInfo> m_info;
112 operator<<(std::ostream& os,
const EventId& eventId);
138 Scheduler(boost::asio::io_service& ioService);
155 cancelImpl(
const shared_ptr<EventInfo>&
info);
168 executeEvent(
const boost::system::error_code& code);
171 class EventQueueCompare
175 operator()(
const shared_ptr<EventInfo>& a,
const shared_ptr<EventInfo>& b)
const noexcept;
178 using EventQueue = std::multiset<shared_ptr<EventInfo>, EventQueueCompare>;
181 unique_ptr<util::detail::SteadyTimer> m_timer;
182 bool m_isEventExecuting =
false;
190 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.
EventId() noexcept=default
Constructs an empty EventId.
friend bool operator!=(const EventId &lhs, const EventId &rhs) noexcept
Generic time-based scheduler.
void cancelAllEvents()
Cancel all scheduled events.
EventId schedule(time::nanoseconds after, EventCallback callback)
Schedule a one-time event after the specified delay.
Scheduler(boost::asio::io_service &ioService)
std::function< void()> EventCallback
Function to be invoked when a scheduled event expires.
std::ostream & operator<<(std::ostream &os, const EventId &eventId)
boost::chrono::nanoseconds nanoseconds