-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathepoll.h
34 lines (28 loc) · 1.08 KB
/
epoll.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
#pragma once
#include "requestData.h"
#include "timer.h"
#include "util.h"
#include <vector>
#include <unordered_map>
#include <memory>
class Epoll
{
public:
typedef std::shared_ptr<RequestData> SP_ReqData; //typedef作用 定义一个别名
private:
static const int MAXFDS = 1000;
static epoll_event *events;
static SP_ReqData fd2req[MAXFDS];
static int epoll_fd;
static const std::string PATH;
static TimerManager timer_manager;
public:
static int epoll_init(int maxevents, int listen_num);
static int epoll_add(int fd, SP_ReqData request, __uint32_t events);
static int epoll_mod(int fd, SP_ReqData request, __uint32_t events);
static int epoll_del(int fd, __uint32_t events = (EPOLLIN | EPOLLET | EPOLLONESHOT));
static void my_epoll_wait(int listen_fd, int max_events, int timeout);
static void acceptConnection(int listen_fd, int epoll_fd, const std::string path);
static std::vector<SP_ReqData> getEventsRequest(int listen_fd, int events_num, const std::string path);
static void add_timer(SP_ReqData request_data, int timeout);
};