Mir
timer.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2014-2015 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  * Alberto Aguirre <alberto.aguirre@canonical.com>
18  */
19 
20 
21 #ifndef MIR_TIME_TIMER_H_
22 #define MIR_TIME_TIMER_H_
23 
24 #include "mir/time/alarm.h"
25 
26 #include <chrono>
27 #include <functional>
28 #include <memory>
29 
30 namespace mir
31 {
32 namespace time
33 {
34 
35 class Alarm;
36 
37 class Timer
38 {
39 public:
40  Timer() = default;
41  virtual ~Timer() = default;
50  virtual std::unique_ptr<Alarm> notify_in(std::chrono::milliseconds delay,
51  std::function<void()> const& callback) = 0;
60  virtual std::unique_ptr<Alarm> notify_at(Timestamp time_point,
61  std::function<void()> const& callback) = 0;
69  virtual std::unique_ptr<Alarm> create_alarm(std::function<void()> const& callback) = 0;
70 
91  virtual std::unique_ptr<Alarm> create_alarm(std::function<void()> const& callback,
92  std::function<void()> const& lock, std::function<void()> const& unlock) = 0;
93 
94  Timer(Timer const&) = delete;
95  Timer& operator=(Timer const&) = delete;
96 };
97 
98 }
99 }
100 
101 #endif // MIR_TIME_TIMER_H_
Timer & operator=(Timer const &)=delete
virtual std::unique_ptr< Alarm > create_alarm(std::function< void()> const &callback)=0
Create an Alarm that will not fire until scheduled.
All things Mir.
Definition: buffer_stream.h:37
virtual std::unique_ptr< Alarm > notify_at(Timestamp time_point, std::function< void()> const &callback)=0
Create an Alarm that calls the callback at the specified time.
std::chrono::steady_clock::time_point Timestamp
Definition: types.h:29
Definition: timer.h:37
virtual ~Timer()=default
virtual std::unique_ptr< Alarm > notify_in(std::chrono::milliseconds delay, std::function< void()> const &callback)=0
Create an Alarm that calls the callback after the specified delay.

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Mar 24 16:15:19 UTC 2015