-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.h
More file actions
36 lines (28 loc) · 746 Bytes
/
timer.h
File metadata and controls
36 lines (28 loc) · 746 Bytes
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
36
#pragma once
extern "C" {
# include <time.h>
}
#include <map>
#include <set>
#include "moment.h"
#include "thread.h"
class Timer : protected Thread {
public:
Timer();
virtual ~Timer();
bool add(Moment delay, uint64_t id);
bool remove(uint64_t id);
protected:
virtual void action(uint64_t id) = 0;
private:
bool run();
private:
typedef std::set<int> SignalNo_t;
typedef Moment DelayTime_t;
typedef std::multimap<DelayTime_t, uint64_t> Delays_t;
typedef std::map<uint64_t, DelayTime_t> SubscriberIDs_t;
int _signo;
Delays_t _delays;
SubscriberIDs_t _sub_ids;
Moment _begin_time;
};