From 17f96bc6414fa58f9ec1dc8bc57ffeab9d312d7f Mon Sep 17 00:00:00 2001 From: Gary Linscott Date: Sun, 11 Oct 2015 03:10:34 +0800 Subject: [PATCH] Revert "Delay waiting for threads to finish" This reverts commit 35e649d70d6426a311325de221af797f864d171b. We need to be sure all threads are finished before sending 'bestmove'. --- src/search.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 207616ef..e65fbc91 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -306,6 +306,11 @@ void MainThread::think() { // Stop the threads and the timer Signals.stop = true; Threads.timer->run = false; + + // Wait until all threads have finished + for (Thread* th : Threads) + if (th != this) + th->wait_while(th->searching); } // When playing in 'nodes as time' mode, subtract the searched nodes from @@ -330,12 +335,6 @@ void MainThread::think() { std::cout << " ponder " << UCI::move(rootMoves[0].pv[1], pos.is_chess960()); std::cout << sync_endl; - - // Wait until all threads have finished before returning. Best move is already - // sent, so this waiting time is not accounted. - for (Thread* th : Threads) - if (th != this) - th->wait_while(th->searching); }