为什么boost serial_executor的worker_thread需要第二个while循环?

时间:2019-04-11 11:55:49

标签: boost

我正在尝试了解boost.thread.executor.serial_executor的源代码。

serial_executor.hpp, line 112中,我们可以看到worker_thread函数中有两个while循环:

/**
* The main loop of the worker thread
*/
void worker_thread()
{
   while (!closed())
   {
        schedule_one_or_yield();
   }
   while (try_executing_one())
   {
   }
}

似乎第一个循环完成了,应该关闭work_queue,然后try_executing_one不会再返回true,所以第二个循环不会执行任何操作,是吗?

那么,第二个while循环的目的是什么?

谢谢。

0 个答案:

没有答案
相关问题