Skip to content

Commit 42bed3a

Browse files
wilxprogschj
authored andcommitted
Use two argument condition_variable::wait() instead of a loop.
1 parent 68f99d8 commit 42bed3a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ThreadPool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ inline ThreadPool::ThreadPool(size_t threads)
4444

4545
{
4646
std::unique_lock<std::mutex> lock(this->queue_mutex);
47-
while(!this->stop && this->tasks.empty())
48-
this->condition.wait(lock);
47+
this->condition.wait(lock,
48+
[this]{ return this->stop || !this->tasks.empty(); });
4949
if(this->stop && this->tasks.empty())
5050
return;
5151
task = std::move(this->tasks.front());

0 commit comments

Comments
 (0)