1 Star 0 Fork 0

pulin88 / mymuduo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
EPollPoller.h 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
vmware_centos_pulin 提交于 2022-02-12 01:40 . mymuduo init
#pragma once
#include "Poller.h"
#include <vector>
#include <sys/epoll.h>
class EventLoop;
/**
* epoll的使用
* epoll_create
* epoll_ctl add/mod/del
* epoll_wait
*/
class EPollPoller : public Poller
{
public:
EPollPoller(EventLoop *loop);
~EPollPoller();
/**
* poll = epoll_wait
* updateChannel 和 removeChannel = epoll_ctl add/del
* 给所有IO复用保留统一的接口
*/
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;
// 更新channel通道
void update(int operation, Channel *channel);
// EventList保存epoll_wait返回的事件
// epoll_wait的共用体data保存channel
using EventList = std::vector<epoll_event>;
int epollfd_;
EventList events_;
};
C++
1
https://gitee.com/pulin88/mymuduo.git
git@gitee.com:pulin88/mymuduo.git
pulin88
mymuduo
mymuduo
main

搜索帮助