]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Simplify finished search in ponder/infinite mode.
[stockfish] / src / search.cpp
index 3c638ca057f5e1c3c515498e005cecf88a111c8e..68069c23c5afc610c0c949c58a3b29315575a676 100644 (file)
@@ -277,13 +277,13 @@ void MainThread::search() {
   // the UCI protocol states that we shouldn't print the best move before the
   // GUI sends a "stop" or "ponderhit" command. We therefore simply wait here
   // until the GUI sends one of those commands (which also raises Threads.stop).
-  if (!Threads.stop && (Threads.ponder || Limits.infinite))
-  {
-      Threads.stopOnPonderhit = true;
-      wait(Threads.stop);
-  }
+  Threads.stopOnPonderhit = true;
+
+  while (!Threads.stop && (Threads.ponder || Limits.infinite))
+  {} // Busy wait for a stop or a ponder reset
 
-  // Stop the threads if not already stopped
+  // Stop the threads if not already stopped (also raise the stop if
+  // "ponderhit" just reset Threads.ponder).
   Threads.stop = true;
 
   // Wait until all threads have finished