#EventLoopThreadPool Class`源码阅读(muduo::net)
如果有问题,欢迎交流!!!
数据成员
EventLoop* baseLoop_
EventLoopTreadPool Class对象所在loop。有些成员函数在执行前要检查当前是不是在baseLoop_所在线程
string name_
用于给一众
EventLoopThread命名
int numThreads_
创建的线程数量
next_
下一个
EventLoop对象
std::vector<std::unique_ptr<EventLoopThread>> threads_
干嘛的一目了然
std::vector<EventLoop*> loops_
成员函数
EventLoopThreadPool(EventLoop* baseLoop, const string& nameArg)
构造函数
~EventLoopThreadPool()
void start(const ThreadInitCallback& cb = ThreadInitCallback())
创建
numThreads_数量的loop线程,并传递cb作为参数
EventLoop* getNextLoop()
返回下一个
EventLoop对象地址
EventLoop* getLoopForHash(size_t hashCode)
返回
hashCode/loops_.size()指向的EventLoop
本文深入剖析了Muduo库中EventLoopThreadPool类的实现,介绍了其构造、线程创建、EventLoop管理的关键细节,包括数据成员如EventLoop指针、线程池大小等。

被折叠的 条评论
为什么被折叠?



