-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTimer.h
36 lines (29 loc) · 791 Bytes
/
Timer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once
#include <functional>
#include <chrono>
typedef std::chrono::milliseconds Interval;
typedef std::function<void(void)> TimerCallback;
class Timer
{
public:
Timer(const Interval& timer_period, const TimerCallback& timer_callback, bool periodic = false);
~Timer();
void Start();
void Stop();
Interval GetPeriod() const;
void SetPeriod(const Interval& new_period);
TimerCallback GetCallback() const;
void SetCallback(const TimerCallback& new_callback);
bool IsPeriodic() const;
void SetPeriodic(bool periodic);
bool IsRunning() const;
private:
bool InitializeImpl();
void CleanupImpl();
Interval period;
TimerCallback callback;
bool isPeriodic;
bool isRunning;
struct TimerImpl;
TimerImpl *impl;
};