Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复EventLoopThread的析构和EventLoop的loop之间存在的时序问题 #442

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hbzzhtt
Copy link

@hbzzhtt hbzzhtt commented Mar 8, 2020

在运行muduo/muduo/net/tests/EventLoopThreadPool_unittest.cc时发现EventLoopThreadPool::start对于3个EventLoopThread的情况存在一些时序上的问题,我列在了这里https:/chenshuo/muduo/issues/441。

其原因我认为是EventLoopThreadPoll::startLoop里面的EventLoopThread::threadFunc还没执行到EventLoop::loop,就发生了EventLoopThreadPoll的析构,此时EventLoop::quit发生在EventLoop::loop之前,本应该退出的线程的EventLoop::quit_标志位被EventLoop::loop清除(此处你也标注了FIXME),我认为EventLoopThread::threadFunc中启动EventLoop完成的标志应该是EventLoop::loop开始运行,而不是loop_ = &loop; 因此,将cond_.notify();调整到了EventLoop正式开始后才确认EventLoopThread::startLoop操作正式完成,以此修正这个时序问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant