Skip to content

Commit 110bee8

Browse files
committed
2 parents a3fa6ef + e4bc4dc commit 110bee8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/backend/evaluator/simulator/threadPool.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,12 @@ class ThreadPool {
7171
if (new_count < cur) {
7272
size_t kill = cur - new_count;
7373
waitForCompletion();
74-
for (size_t i = 0; i < kill; ++i)
75-
workers[workers.size() - 1 - i]->retire.store(true, std::memory_order_relaxed);
74+
{
75+
std::lock_guard<std::mutex> lock(mtx);
76+
for (size_t i = 0; i < kill; ++i) {
77+
workers[workers.size() - 1 - i]->retire.store(true, std::memory_order_relaxed);
78+
}
79+
}
7680
cv.notify_all(); // wake sleepers so they can retire
7781
for (size_t i = 0; i < kill; ++i) {
7882
auto idx = workers.size() - 1;

0 commit comments

Comments
 (0)