Skip to content

Commit dcb2723

Browse files
committed
Thread pool fix
1 parent 6114edb commit dcb2723

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cpp/OPThreadPool.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,14 @@ void ThreadPool::doWork() {
7474

7575
task = workQueue.front();
7676
workQueue.pop();
77+
++busy;
7778
}
78-
++busy;
7979
task();
80-
--busy;
80+
{
81+
std::lock_guard<std::mutex> g(workQueueMutex);
82+
--busy;
83+
}
84+
workQueueConditionVariable.notify_one();
8185
}
8286
}
8387

0 commit comments

Comments
 (0)