-
Notifications
You must be signed in to change notification settings - Fork 0
/
Channel.cc
45 lines (34 loc) · 802 Bytes
/
Channel.cc
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
#include "Channel.h"
#include <unistd.h>
#include <cstdlib>
#include <iostream>
#include <queue>
#include "Epoll.h"
#include "EventLoop.h"
#include "Util.h"
using namespace std;
Channel::Channel(EventLoop *loop)
: loop_(loop), events_(0), lastEvents_(0), fd_(0) {}
Channel::Channel(EventLoop *loop, int fd)
: loop_(loop), fd_(fd), events_(0), lastEvents_(0) {}
Channel::~Channel() {
// loop_->poller_->epoll_del(fd, events_);
// close(fd_);
}
int Channel::getFd() { return fd_; }
void Channel::setFd(int fd) { fd_ = fd; }
void Channel::handleRead() {
if (readHandler_) {
readHandler_();
}
}
void Channel::handleWrite() {
if (writeHandler_) {
writeHandler_();
}
}
void Channel::handleConn() {
if (connHandler_) {
connHandler_();
}
}