mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-25 11:36:51 +08:00
allow waiting for task completion.
This commit is contained in:
@@ -98,6 +98,12 @@ void Thread::wait_for_search_finished() {
|
||||
}
|
||||
|
||||
|
||||
void Thread::wait_for_task_finished() {
|
||||
|
||||
std::unique_lock<std::mutex> lk(mutex);
|
||||
cv.wait(lk, [&]{ return !task; });
|
||||
}
|
||||
|
||||
/// Thread::idle_loop() is where the thread is parked, blocked on the
|
||||
/// condition variable, when it has no work to do.
|
||||
|
||||
@@ -293,3 +299,10 @@ void ThreadPool::wait_for_search_finished() const {
|
||||
if (th != front())
|
||||
th->wait_for_search_finished();
|
||||
}
|
||||
|
||||
|
||||
void ThreadPool::wait_for_tasks_finished() const {
|
||||
|
||||
for (Thread* th : *this)
|
||||
th->wait_for_task_finished();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user