Mir
Public Types | Public Member Functions | List of all members
mir::time::Alarm Class Referenceabstract

A one-shot, resettable handle to trigger a callback at a later time. More...

#include <alarm.h>

Public Types

enum  State { pending, cancelled, triggered }
 

Public Member Functions

 Alarm ()=default
 
virtual ~Alarm ()=default
 
virtual bool cancel ()=0
 Cancels a pending alarm. More...
 
virtual State state () const =0
 
virtual bool reschedule_in (std::chrono::milliseconds delay)=0
 Reschedule the alarm. More...
 
virtual bool reschedule_for (Timestamp timeout)=0
 Reschedule the alarm. More...
 
 Alarm (Alarm const &)=delete
 
Alarmoperator= (Alarm const &)=delete
 

Detailed Description

A one-shot, resettable handle to trigger a callback at a later time.

Note
All members of Alarm are threadsafe
All members of Alarm are safe to call from the Alarm's callback

Member Enumeration Documentation

◆ State

Enumerator
pending 

Will trigger the callback at some point in the future.

cancelled 

The callback has been cancelled before being triggered.

triggered 

The callback has been called.

Constructor & Destructor Documentation

◆ Alarm() [1/2]

mir::time::Alarm::Alarm ( )
default

◆ ~Alarm()

virtual mir::time::Alarm::~Alarm ( )
virtualdefault
Note
Destruction of the Alarm guarantees that the callback will not subsequently be called

◆ Alarm() [2/2]

mir::time::Alarm::Alarm ( Alarm const &  )
delete

Member Function Documentation

◆ cancel()

virtual bool mir::time::Alarm::cancel ( )
pure virtual

Cancels a pending alarm.

Note
Has no effect if the Alarm is in the Triggered state.
cancel() is idempotent
Returns
True iff the state of the Alarm is now Cancelled

◆ operator=()

Alarm& mir::time::Alarm::operator= ( Alarm const &  )
delete

◆ reschedule_for()

virtual bool mir::time::Alarm::reschedule_for ( Timestamp  timeout)
pure virtual

Reschedule the alarm.

Parameters
timeoutTime point when the alarm should be triggered
Returns
True if this reschedule supersedes a previous not-yet-triggered timeout
Note
This cancels any previous timeout set.

◆ reschedule_in()

virtual bool mir::time::Alarm::reschedule_in ( std::chrono::milliseconds  delay)
pure virtual

Reschedule the alarm.

Parameters
delayDelay, in milliseconds, before the Alarm will be triggered
Returns
True if this reschedule supersedes a previous not-yet-triggered timeout
Note
This cancels any previous timeout set.

◆ state()

virtual State mir::time::Alarm::state ( ) const
pure virtual

The documentation for this class was generated from the following file:

Copyright © 2012-2016 Canonical Ltd.
Generated on Mon Jun 5 11:07:25 UTC 2017