-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChannel.cpp
82 lines (63 loc) · 1.16 KB
/
Channel.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "Channel.h"
#include "EventLoop.h"
#include "Logging.h"
#include "MemoryPool.h"
typedef std::shared_ptr<Channel> SP_Channel;
Channel::Channel(SP_EventLoop Loop)
: loop(Loop),
deleted(false),
First(true)
{
}
Channel::~Channel(){
LOG<<"delete fd="<<fd;
Close(fd);
}
void Channel::setReadhandler(CallBack &&readHandler){
readhandler=readHandler;
}
void Channel::setWritehandler(CallBack &&writeHandler){
writehandler=writeHandler;
}
void Channel::setClosehandler(CallBack &&closeHandler){
closehandler=closeHandler;
}
void Channel::setDeleted(bool Deleted){
deleted=Deleted;
}
void Channel::handleEvent(){
if(events&EPOLLIN)
readhandler();
else if(events&EPOLLOUT)
writehandler();
}
void Channel::handleClose(){
closehandler();
}
void Channel::setnotFirst(){
First=false;
}
void Channel::setFd(int Fd){
fd=Fd;
}
void Channel::setRevents(int Revents){
revents=Revents;
}
void Channel::setEvents(int Events){
events=Events;
}
int Channel::getFd(){
return fd;
}
int Channel::getRevents(){
return revents;
}
bool Channel::isDeleted(){
return deleted;
}
bool Channel::isFirst(){
return First;
}
WP_EventLoop Channel::getLoop(){
return loop;
}