ndn::util::scheduler::ScopedEventId Class Reference

A scoped handle of scheduled event. More...

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

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

Public Member Functions

 ScopedEventId () noexcept=default
 
 ScopedEventId (Scheduler &) noexcept
 
void cancel ()
 Cancel the operation. More...
 
CancelHandle release ()
 Release the operation so that it won't be cancelled when this ScopedCancelHandle is destructed. More...
 

Detailed Description

A scoped handle of 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
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 127 of file scheduler.hpp.

Constructor & Destructor Documentation

ndn::util::scheduler::ScopedEventId::ScopedEventId ( )
defaultnoexcept
ndn::util::scheduler::ScopedEventId::ScopedEventId ( Scheduler )
inlineexplicitnoexcept
Deprecated:
Scheduler argument is no longer necessary.

Use default construction instead.

Definition at line 138 of file scheduler.hpp.

Member Function Documentation

void ndn::detail::ScopedCancelHandle::cancel ( )
inherited

Cancel the operation.

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

CancelHandle ndn::detail::ScopedCancelHandle::release ( )
inherited

Release the operation so that it won't be cancelled when this ScopedCancelHandle is destructed.

Returns
the CancelHandle.

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