-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventLoopThreadPool.h
More file actions
35 lines (29 loc) · 923 Bytes
/
EventLoopThreadPool.h
File metadata and controls
35 lines (29 loc) · 923 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
#ifndef _EVENTLOOP_THREAD_POOL_H
#define _EVENTLOOP_THREAD_POOL_H
#include "Condition.h"
#include "Mutex.h"
#include <vector>
#include <boost/function.hpp>
#include <boost/noncopyable.hpp>
#include <boost/noncopyable.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
class EventLoop;
class EventLoopThread;
class EventLoopThreadPool : boost::noncopyable
{
public:
typedef boost::function<void(EventLoop*)> ThreadInitCallback;
EventLoopThreadPool(EventLoop* baseloop);
~EventLoopThreadPool();
void setThreadNum(int threadnum){ m_threadsNum = threadnum; }
void start(const ThreadInitCallback& cb = ThreadInitCallback());
EventLoop* getNextLoop();
private:
EventLoop* m_baseLoop;
bool m_started;
int m_threadsNum;
int m_next;
boost::ptr_vector<EventLoopThread> m_threads;
std::vector<EventLoop*> m_loops;
};
#endif