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 associated event is valid. More...
 
void reset () noexcept
 Clear this EventId without canceling the associated event. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const EventId &eventId)
 
bool operator== (const EventId &lhs, const EventId &rhs) noexcept
 Determine whether lhs and rhs 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 61 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 27 of file cancel-handle.cpp.

◆ operator bool()

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

Determine whether the associated event is valid.

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

Definition at line 51 of file scheduler.cpp.

◆ reset()

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

Clear this EventId without canceling the associated event.

Postcondition
!(*this)

Definition at line 58 of file scheduler.cpp.

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 104 of file scheduler.hpp.

◆ operator==

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

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

Definition at line 97 of file scheduler.hpp.