ndn::util::scheduler::EventId Class Reference

A handle of scheduled event. More...

#include <ndn-cxx/util/scheduler.hpp>

+ Inheritance diagram for ndn::util::scheduler::EventId:
+ Collaboration diagram for ndn::util::scheduler::EventId:

Public Member Functions

 EventId () noexcept=default
 Constructs an empty EventId. More...
 
 EventId (std::nullptr_t) noexcept
 Allow implicit conversion from nullptr. More...
 
void cancel () const
 Cancel the operation. More...
 
 operator bool () const noexcept
 Determine whether the event is valid. More...
 
bool operator!= (const EventId &other) const noexcept
 
bool operator== (const EventId &other) const noexcept
 Determine whether this and other refer to the same event, or are both empty/expired/cancelled. More...
 
void reset () noexcept
 Clear this EventId without canceling. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const EventId &eventId)
 
class Scheduler
 

Detailed Description

A handle of scheduled event.

EventId eid = scheduler.schedule(10_ms, [] { doSomething(); });
eid.cancel(); // cancel the event
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 59 of file scheduler.hpp.

Constructor & Destructor Documentation

ndn::util::scheduler::EventId::EventId ( )
defaultnoexcept

Constructs an empty EventId.

ndn::util::scheduler::EventId::EventId ( std::nullptr_t  )
inlinenoexcept

Allow implicit conversion from nullptr.

Definition at line 69 of file scheduler.hpp.

Member Function Documentation

void ndn::detail::CancelHandle::cancel ( ) const
inherited

Cancel the operation.

Definition at line 33 of file cancel-handle.cpp.

ndn::util::scheduler::EventId::operator bool ( ) const
explicitnoexcept

Determine whether the event is valid.

Return values
trueThe event is valid.
falseThis EventId is empty, or the event is expired or cancelled.

Definition at line 61 of file scheduler.cpp.

bool ndn::util::scheduler::EventId::operator!= ( const EventId other) const
inlinenoexcept

Definition at line 87 of file scheduler.hpp.

bool ndn::util::scheduler::EventId::operator== ( const EventId other) const
noexcept

Determine whether this and other refer to the same event, or are both empty/expired/cancelled.

Definition at line 68 of file scheduler.cpp.

void ndn::util::scheduler::EventId::reset ( )
noexcept

Clear this EventId without canceling.

Postcondition
!(*this)

Definition at line 75 of file scheduler.cpp.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const EventId eventId 
)
friend

Definition at line 81 of file scheduler.cpp.

friend class Scheduler
friend

Definition at line 104 of file scheduler.hpp.