-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathepoll.h
More file actions
58 lines (37 loc) · 1006 Bytes
/
epoll.h
File metadata and controls
58 lines (37 loc) · 1006 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* 这是ANSI文档 */
#ifndef __LIB__EPOLL__H__
#define __LIB__EPOLL__H__
#ifdef __cplusplus
#include <sys/epoll.h>
class Lib_Epoll
{
public:
// TODO: 公有类析构函数,必须公有
~Lib_Epoll(void);
bool checkListen(int fd);
void setPtr(void *ptr);
void *getPtr(void);
unsigned int size(void);
bool ctl(int fd, bool is_add);
bool add(int fd, bool is_listen = false);
bool del(int fd, bool is_close = true);
void quit(void);
bool loop(void);
void wait(int timeout, void (*handle_call)(void *arg, int fd), void *arg = NULL);
void wait(int timeout, void (*handle_call)(Lib_Epoll *epoll, int fd, void *arg), void *arg = NULL);
int waitSingle(int timeout);
static Lib_Epoll *getObject(int count = 512);
private:
// TODO: 私有类构造函数,私有是防止直接构建对象
// TODO: 只能通过getObject创建对象
// TODO: 因为getObject可以判断参数是否合法
Lib_Epoll(void);
int m_fd;
struct epoll_event *m_events;
int m_count;
unsigned int m_nums;
int m_listen;
void *m_ptr;
};
#endif
#endif