Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
timer.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 
20 #ifndef MIR_TIME_TIMER_H_
21 #define MIR_TIME_TIMER_H_
22 
23 #include "mir/time/alarm.h"
24 
25 #include <chrono>
26 #include <functional>
27 #include <memory>
28 
29 namespace mir
30 {
31 namespace time
32 {
33 
34 class Alarm;
35 
36 class Timer
37 {
38 public:
39  Timer() = default;
40  virtual ~Timer() = default;
49  virtual std::unique_ptr<Alarm> notify_in(std::chrono::milliseconds delay,
50  std::function<void()> callback) = 0;
59  virtual std::unique_ptr<Alarm> notify_at(Timestamp time_point,
60  std::function<void()> callback) = 0;
68  virtual std::unique_ptr<Alarm> create_alarm(std::function<void()> callback) = 0;
69 
70  Timer(Timer const&) = delete;
71  Timer& operator=(Timer const&) = delete;
72 };
73 
74 }
75 }
76 
77 #endif // MIR_TIME_TIMER_H_
Timer & operator=(Timer const &)=delete
All things Mir.
Definition: aging_buffer.h:24
std::chrono::high_resolution_clock::time_point Timestamp
Definition: clock.h:29
virtual std::unique_ptr< Alarm > create_alarm(std::function< void()> callback)=0
Create an Alarm that will not fire until scheduled.
virtual std::unique_ptr< Alarm > notify_at(Timestamp time_point, std::function< void()> callback)=0
Create an Alarm that calls the callback at the specified time.
Definition: timer.h:36
virtual ~Timer()=default
virtual std::unique_ptr< Alarm > notify_in(std::chrono::milliseconds delay, std::function< void()> callback)=0
Create an Alarm that calls the callback after the specified delay.

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014