Skip to content

Commit

Permalink
Lock ThreadPool::jobs_mutex_ when setting should_stop_ to true.
Browse files Browse the repository at this point in the history
  • Loading branch information
aliddell committed Nov 17, 2023
1 parent 6eb136a commit bb673c1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ common::ThreadPool::push_to_job_queue(JobT&& job)
void
common::ThreadPool::await_stop() noexcept
{
should_stop_ = true;
{
std::scoped_lock lock(jobs_mutex_);
should_stop_ = true;
}

cv_.notify_all();

// spin down threads
Expand Down

0 comments on commit bb673c1

Please sign in to comment.