Mir
alarm.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2014 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17  */
18 
19 #ifndef MIR_TIME_ALARM_H_
20 #define MIR_TIME_ALARM_H_
21 
22 #include "mir/time/types.h"
23 
24 namespace mir
25 {
26 namespace time
27 {
28 
34 class Alarm
35 {
36 public:
37  enum State
38  {
42  };
43 
44 
45  Alarm() = default;
49  virtual ~Alarm() = default;
50 
59  virtual bool cancel() = 0;
60  virtual State state() const = 0;
61 
69  virtual bool reschedule_in(std::chrono::milliseconds delay) = 0;
70 
78  virtual bool reschedule_for(Timestamp timeout) = 0;
79 
80  Alarm(Alarm const&) = delete;
81  Alarm& operator=(Alarm const&) = delete;
82 };
83 
84 }
85 }
86 #endif
Definition: as_render_target.h:27
Will trigger the callback at some point in the future.
Definition: alarm.h:39
Alarm & operator=(Alarm const &)=delete
A one-shot, resettable handle to trigger a callback at a later time.
Definition: alarm.h:34
virtual bool reschedule_in(std::chrono::milliseconds delay)=0
Reschedule the alarm.
virtual bool reschedule_for(Timestamp timeout)=0
Reschedule the alarm.
std::chrono::steady_clock::time_point Timestamp
Definition: types.h:29
virtual State state() const =0
virtual bool cancel()=0
Cancels a pending alarm.
virtual ~Alarm()=default
State
Definition: alarm.h:37
The callback has been cancelled before being triggered.
Definition: alarm.h:40
The callback has been called.
Definition: alarm.h:41

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