| 10 | // one loop per thread |
| 11 | class EventLoop; |
| 12 | class EventLoopThread : noncopyable |
| 13 | { |
| 14 | public: |
| 15 | using ThreadInitCallback = std::function<void(EventLoop*)>; |
| 16 | |
| 17 | EventLoopThread(const ThreadInitCallback &cb = ThreadInitCallback(), |
| 18 | const std::string &name = std::string()); |
| 19 | ~EventLoopThread(); |
| 20 | |
| 21 | EventLoop *startLoop(); // 开启线程池 |
| 22 | |
| 23 | private: |
| 24 | void threadFunc(); |
| 25 | |
| 26 | // EventLoopThread::threadFunc 会创建 EventLoop |
| 27 | EventLoop *loop_; |
| 28 | bool exiting_; |
| 29 | Thread thread_; |
| 30 | std::mutex mutex_; |
| 31 | std::condition_variable cond_; |
| 32 | ThreadInitCallback callback_; |
| 33 | |
| 34 | }; |
| 35 | |
| 36 | #endif // EVENT_LOOP_THREAD_H |
nothing calls this directly
no outgoing calls
no test coverage detected