forked from voidccc/mini-muduo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventLoop.h
45 lines (40 loc) · 1.07 KB
/
EventLoop.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
43
44
45
//author voidccc
#ifndef EVENTLOOP_H
#define EVENTLOOP_H
#include "Declear.h"
#include "IChannelCallback.h"
#include "Task.h"
#include "Mutex.h"
#include <vector>
using namespace std;
class EventLoop : public IChannelCallback
{
public:
EventLoop();
~EventLoop();
void loop();
void update(Channel* pChannel);
void queueInLoop(Task& task);
void runInLoop(Task& task);
int runAt(Timestamp when, IRun0* pRun);
int runAfter(double delay, IRun0* pRun);
int runEvery(double interval, IRun0* pRun);
void cancelTimer(int timerfd);
bool isInLoopThread();
virtual void handleRead();
virtual void handleWrite();
private:
void wakeup();
int createEventfd();
void doPendingFunctors();
bool _quit;
bool _callingPendingFunctors;
Epoll* _pPoller;
int _eventfd;
const pid_t _threadId;
Channel* _pEventfdChannel;
MutexLock _mutex;
vector<Task> _pendingFunctors;
TimerQueue* _pTimerQueue;
};
#endif