X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=205e992723108b2b90c750706235410c7da1baf9;hp=58a52831a729c9f69cd15fd9e72210c7fea6decc;hb=ce84ab6e9dc64e0c137c2785a36e4a345a8a5a95;hpb=fca8dbc0295c27ee8b2e3ee8cc217edd36f20127 diff --git a/src/search.cpp b/src/search.cpp index 58a52831..205e9927 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -300,14 +300,6 @@ void MainThread::think() { } search(true); // Let's start searching! - - // Stop the threads - Signals.stop = true; - - // 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 @@ -326,6 +318,14 @@ void MainThread::think() { wait(Signals.stop); } + // Stop the threads if not already stopped + Signals.stop = true; + + // Wait until all threads have finished + for (Thread* th : Threads) + if (th != this) + th->wait_while(th->searching); + // Check if there are threads with a better score than main thread. Thread* bestThread = this; for (Thread* th : Threads)