-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChannel.h
42 lines (38 loc) · 952 Bytes
/
Channel.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
35
36
37
38
39
40
41
42
#pragma once
#include <functional>
#include <memory>
#include <sys/epoll.h>
class EventLoop;
typedef std::shared_ptr<EventLoop> SP_EventLoop;
typedef std::weak_ptr<EventLoop> WP_EventLoop;
typedef std::function<void()> CallBack;
class Channel{
public:
Channel(SP_EventLoop Loop);
~Channel();
void setReadhandler(CallBack&& readhandler);
void setWritehandler(CallBack &&writeHandler);
void setClosehandler(CallBack &&closeHandler);
void handleEvent();
void handleClose();
void setDeleted(bool Deleted);
void setFd(int Fd);
void setRevents(int Revents);
void setEvents(int Events);
void setnotFirst();
bool isFirst();
int getFd();
int getRevents();
bool isDeleted();
WP_EventLoop getLoop();
private:
int fd;
int events; //want to do
int revents; //now doing
bool deleted;
bool First;
WP_EventLoop loop;
CallBack readhandler;
CallBack writehandler;
CallBack closehandler;
};