#pragma once
#include <iostream>
using namespace std;
#include <sys/epoll.h>
#include <vector>
#define MAX_EVENT_NUM 256
class CEpoll
{
public:
CEpoll();
~CEpoll();
public:
bool Create(int size);
void Close();
bool AddFd(int fd, int eventMod, bool isNonBlock);
bool ModFd(int fd, int eventMod);
bool DelFd(int fd);
int Wait(int maxEventNum, int timeOut, int* fdArray); //milliseconds
enum Events{
IN = EPOLLIN, //read
OUT = EPOLLOUT, //write
//ET = EPOLLET //edge h_speed
};
private:
int SetNonBlock(int fd);
private:
int m_epollFd;
vector<int> m_fd;
};
评论0