-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy patheventloopthreadpool.h
More file actions
43 lines (33 loc) · 867 Bytes
/
eventloopthreadpool.h
File metadata and controls
43 lines (33 loc) · 867 Bytes
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
#pragma once
#ifndef EVENTLOOPTHREADPOOL_H
#define EVENTLOOPTHREADPOOL_H
#include <vector>
#include <memory>
#include "base/thread.h"
#include "eventloopthread.h"
class EventLoopThreadPool
{
public:
typedef EventLoopThread::CallbackType CallbackType;
explicit EventLoopThreadPool(int threadCnt);
~EventLoopThreadPool();
void SetReadCallback(CallbackType readCallback);
void SetWriteCallback(CallbackType writeCallback);
void SetErrorCallback(CallbackType errorCallback);
void PushFd(int fd);
void Loop();
void Quit();
int GetThreadCnt();
bool Empty();
private:
void RunInThread(int threadId);
private:
int m_threadCnt;
int m_robinIndex;
std::vector<std::unique_ptr<Thread>> m_threads;
std::vector<EventLoopThread *> m_eventLoopThreads;
CallbackType m_readCallback;
CallbackType m_writeCallback;
CallbackType m_errorCallback;
};
#endif