MCPcopy Create free account
hub / github.com/Shangyizhou/A-Tiny-Network-Library / EventLoopThread

Class EventLoopThread

src/net/EventLoopThread.h:12–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10// one loop per thread
11class EventLoop;
12class EventLoopThread : noncopyable
13{
14public:
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
23private:
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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected