Introduce and use wait_for_search_finished()
[stockfish] / src / uci.cpp
index 718c78752502b61bd991b25191c94b2d30487e41..987da9c1f879ec7304184092ffa14028c5dab396 100644 (file)
@@ -67,7 +67,10 @@ void uci_loop() {
       is >> skipws >> token;
 
       if (token == "quit" || token == "stop")
-          Threads.stop_thinking();
+      {
+          Search::Signals.stop = true;
+          Threads.wait_for_search_finished(); // Cannot quit while threads are running
+      }
 
       else if (token == "ponderhit")
       {
@@ -77,7 +80,10 @@ void uci_loop() {
           Search::Limits.ponder = false;
 
           if (Search::Signals.stopOnPonderhit)
-              Threads.stop_thinking();
+          {
+              Search::Signals.stop = true;
+              Threads.wait_for_search_finished();
+          }
       }
 
       else if (token == "go")
@@ -223,7 +229,7 @@ namespace {
     limits.time = time[pos.side_to_move()];
     limits.increment = inc[pos.side_to_move()];
 
-    Threads.start_thinking(pos, limits, searchMoves, true);
+    Threads.start_searching(pos, limits, searchMoves, true);
   }