Skip to content

Commit 629a28b

Browse files
authored
Merge pull request #189 from c-jimenez/fix/thread_pool_stop
[tools] Fix thread pool stop race condition
2 parents 1b944d0 + 55ab75d commit 629a28b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/tools/helpers/WorkerThreadPool.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ class Job : public JobBase<ReturnType>
9595
}
9696

9797
// Notify end of job
98-
this->end = true;
98+
{
99+
std::lock_guard<std::mutex> lock(this->end_of_job_mutex);
100+
this->end = true;
101+
}
99102
this->end_of_job_var.notify_all();
100103
}
101104

@@ -132,7 +135,10 @@ class Job<void> : public JobBase<void>
132135
}
133136

134137
// Notify end of job
135-
this->end = true;
138+
{
139+
std::lock_guard<std::mutex> lock(this->end_of_job_mutex);
140+
this->end = true;
141+
}
136142
this->end_of_job_var.notify_all();
137143
}
138144

0 commit comments

Comments
 (0)