我正在尝试了解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循环的目的是什么?
谢谢。