summaryrefslogtreecommitdiff
path: root/tvapi/libtv/tvutils/zepoll.h (plain)
blob: 3fc6856a5da6b3aa261325c9f2bc77b0676cdc66
1
2#ifndef EPOLL_H
3#define EPOLL_H
4
5#include <sys/epoll.h>
6#include <unistd.h>
7
8
9/**
10 * @brief The Epoll class 对epoll的封装
11 */
12class Epoll {
13public:
14 /**
15 *
16 */
17 enum EPOLL_OP {ADD = EPOLL_CTL_ADD, MOD = EPOLL_CTL_MOD, DEL = EPOLL_CTL_DEL};
18 /**
19 * 最大的连接数和最大的回传事件数
20 */
21 Epoll(int _max = 30, int maxevents = 20);
22 ~Epoll();
23 int create();
24 int add(int fd, epoll_event *event);
25 int mod(int fd, epoll_event *event);
26 int del(int fd, epoll_event *event);
27 void setTimeout(int timeout);
28 void setMaxEvents(int maxevents);
29 int wait();
30 const epoll_event *events() const;
31 const epoll_event &operator[](int index)
32 {
33 return backEvents[index];
34 }
35private:
36 bool isValid() const;
37 int max;
38 int epoll_fd;
39 int epoll_timeout;
40 int epoll_maxevents;
41 epoll_event *backEvents;
42};
43
44
45
46
47#endif //EPOLL_H
48
49