-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask.h
More file actions
54 lines (42 loc) · 1.15 KB
/
Task.h
File metadata and controls
54 lines (42 loc) · 1.15 KB
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
//
// Created by parallels on 2020/1/19.
//
#ifndef WEB_SERVER1_1_TASK_H
#define WEB_SERVER1_1_TASK_H
#include <stdint.h>
#include "Epoll.h"
#include <functional>
#include "EventLoop.h"
class EventLoop;
class Epoll;
class HttpData;
class Task {
public:
Task(EventLoop *loop, int fd);
~Task();
typedef std::function<void()> func;
int fd_;
int rfd_;
__uint32_t events;
__uint32_t revents;
func connHandle_;
func readHandle_;
func writeHandle_;
int getFd() {return fd_;}
//void addToEpoll() {epoll_->addEpoll(this);}
Epoll *epoll_;
void setConnHandle(func &&func_) {connHandle_ = func_;}
void setReadHandle(func &&func_) {readHandle_ = func_;}
void setWriteHandle(func &&func_) {writeHandle_ = func_;}
void eventHandle();
bool isMainLoop() {return isMainLoop_;}
void setMainLoop() {isMainLoop_ = true;}
void setHolder(std::shared_ptr<HttpData> holder) { holder_ = holder; }
std::shared_ptr<HttpData> getHolder() { return holder_; }
void clearHolder();
private:
std::shared_ptr<HttpData> holder_;
EventLoop *loop_;
bool isMainLoop_;
};
#endif //WEB_SERVER1_1_TASK_H