progschj / ThreadPool

A simple C++11 Thread Pool implementation
zlib License
7.63k stars 2.21k forks source link

a #112

Open fanhoumin opened 2 months ago

fanhoumin commented 2 months ago

When I use your thread library, I encountered an interesting issue. Is the following conditional redundant? Because theoretically, if our thread is not in a stopped state but the task queue is empty, it shouldn't leave the waiting state.std::unique_lock<std::mutex> lock(this->queue_mutex); this->condition.wait(lock, [this]{ return this->stop || !this->tasks.empty(); }); if(this->stop && this->tasks.empty()) return;