-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCleanerTimer.h
70 lines (55 loc) · 1.14 KB
/
CleanerTimer.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* File: CleanerTimer.h
* Author: try
*
* Created on 2011年7月11日, 上午9:39
*/
#ifndef CLEANERTIMER_H
#define CLEANERTIMER_H
#include <vector>
#include <hash_set>
#include "libev.h"
#include "resources.h"
#include "ICleaner.h"
/**
* 资源清理定时器
*/
class CleanerTimer {
private:
CleanerTimer();
virtual ~CleanerTimer();
public:
static CleanerTimer instance;
/**
* 添加一个 Cleaner
*
* @param c 实现了Cleaner接口的类型实例
*/
void add(ICleaner* c);
/**
* 手动执行清理工作
*/
void cleanupAll();
/**
* 移除Cleaner
*/
void remove(ICleaner* c);
/**
* 停止
*/
void stop();
// /**
// * 清除定时器
// */
// void clear(){
// cleaners.clear();
// }
private:
typedef __gnu_cxx::hash_set<ICleaner*, PointerHash, PointerCompare> CleanerSet;
// typedef std::vector<ICleaner*> Cleaners;
CleanerSet cleaners;
private:
ev::timer timeoutTimer;
void timerCallback(ev::timer& timer, int events);
};
#endif /* CLEANERTIMER_H */