-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEpollPoller.h
More file actions
36 lines (29 loc) · 890 Bytes
/
Copy pathEpollPoller.h
File metadata and controls
36 lines (29 loc) · 890 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
#pragma once
#include "Poller.h"
#include "Timestamp.h"
#include <vector>
#include <sys/epoll.h>
class Channel;
/*
* epoll 的使用
* epoll_create
* epoll_ctl
* epoll_wait
*/
class EpollPoller : public Poller{
public:
EpollPoller(EventLoop* loop);
~EpollPoller() override;
/* 重写基类Poller的抽象方法 */
Timestamp poll(int timeoutMs, ChannelList* activeChannels) override;
void updateChannel(Channel* channel) override;
void removeChannel(Channel* channel) override;
private:
static const int kInitEventListSize = 16;
/* 辅助函数 */
void fillactiveChannels(int numevents,ChannelList* activeChannels) const; /* 填写活跃连接 */
void update(int operation, Channel* Channel); /* 更新Channel通道 */
using EventList = std::vector<epoll_event>;
int epollfd_;
EventList events_;
};