-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEpoll.h
34 lines (29 loc) · 905 Bytes
/
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 "Channel.h"
#include "HttpData.h"
#include "Timer.h"
#include <memory>
#include <vector>
#include <sys/epoll.h>
class Channel;
class HttpData;
class Epoll {
public:
Epoll();
~Epoll();
void epoll_add(std::shared_ptr<Channel> request, int timeout);
void epoll_mod(std::shared_ptr<Channel> request, int timeout);
void epoll_del(std::shared_ptr<Channel> request);
std::vector<std::shared_ptr<Channel>> poll();
std::vector<std::shared_ptr<Channel>> getEventsRequest(int events_num);
void add_timer(std::shared_ptr<Channel> request_data, int timeout);
int getEpollFd() { return epollFd_; }
void handleExpired();
private:
static const int MAXFDS = 100000;
int epollFd_;
std::vector<epoll_event> events_;
std::shared_ptr<Channel> fd2chan_[MAXFDS];
std::shared_ptr<HttpData> fd2http_[MAXFDS];
TimerManager timerManager_;
};