ndn::scheduler Namespace Reference

Classes

class  EventId
 A handle for a scheduled event. More...
 
class  Scheduler
 Generic time-based event scheduler. More...
 

Typedefs

using EventCallback = std::function< void()>
 Function to be invoked when a scheduled event expires. More...
 
using ScopedEventId = detail::ScopedCancelHandle< EventId >
 A scoped handle for a scheduled event. More...
 

Typedef Documentation

◆ EventCallback

using ndn::scheduler::EventCallback = typedef std::function<void()>

Function to be invoked when a scheduled event expires.

Definition at line 48 of file scheduler.hpp.

◆ ScopedEventId

A scoped handle for a scheduled event.

Upon destruction of this handle, the event is canceled automatically. Most commonly, the application keeps a ScopedEventId as a class member field, so that it can cleanup its event when the class instance is destructed.

{
ScopedEventId eid = scheduler.schedule(10_ms, [] { doSomething(); });
} // eid goes out of scope, canceling the event
detail::ScopedCancelHandle< EventId > ScopedEventId
A scoped handle for a scheduled event.
Definition: scheduler.hpp:132
Note
Canceling an expired (executed) or canceled event has no effect.
Warning
Canceling an event after the scheduler has been destructed may trigger undefined behavior.

Definition at line 132 of file scheduler.hpp.