ndn::scheduler::EventId Class Reference

A handle for a scheduled event. More...

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

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

Public Member Functions

 EventId () noexcept=default
 Constructs an empty EventId. More...
 
void cancel () const
 Cancel the operation. More...
 
 operator bool () const noexcept
 Determine whether the event is valid. More...
 
void reset () noexcept
 Clear this EventId without canceling. More...
 

Friends

bool operator!= (const EventId &lhs, const EventId &rhs) noexcept
 
std::ostream & operator<< (std::ostream &os, const EventId &eventId)
 
bool operator== (const EventId &lhs, const EventId &rhs) noexcept
 Determine whether this and other refer to the same event, or are both empty/expired/cancelled. More...
 

Detailed Description

A handle for a scheduled event.

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

Constructor & Destructor Documentation

◆ EventId()

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

Constructs an empty EventId.

Member Function Documentation

◆ cancel()

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

Cancel the operation.

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

◆ operator bool()

ndn::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 59 of file scheduler.cpp.

◆ reset()

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

Clear this EventId without canceling.

Postcondition
!(*this)

Definition at line 66 of file scheduler.cpp.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const EventId lhs,
const EventId rhs 
)
friend

Definition at line 96 of file scheduler.hpp.

◆ operator<<

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

Definition at line 71 of file scheduler.cpp.

◆ operator==

bool operator== ( const EventId lhs,
const EventId rhs 
)
friend

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

Definition at line 88 of file scheduler.hpp.