lzpong / threadpool

based on C++11 , a mini threadpool , accept variable number of parameters 基于C++11的线程池,简洁且可以带任意多的参数

Home Page:http://www.cnblogs.com/lzpong/p/6397997.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

addThread 工作线程函数97行99行

ZhuZouRong opened this issue · comments

commented
                  unique_lock<mutex> lock{ _lock };

96 _task_cv.wait(lock, [this]{
97 return !_run || !_tasks.empty();
98 }); // wait 直到有 task
99 if (!_run && _tasks.empty())
100 return;
_tasks.empty() 为什么要判断两次呢
97 行是队列不为空就继续等待
99 行不也是队列不为空就往下