]> git.sesse.net Git - stockfish/blobdiff - src/uci.cpp
Introduce and use wait_for_search_finished()
[stockfish] / src / uci.cpp
index ed370483435366e62e459ea00a985b3a288ed8f0..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")
@@ -175,14 +181,10 @@ namespace {
     while (is >> token)
         value += string(" ", !value.empty()) + token;
 
-    if (!Options.count(name))
-        cout << "No such option: " << name << endl;
-
-    else if (value.empty()) // UCI buttons don't have a value
-        Options[name] = true;
-
-    else
+    if (Options.count(name))
         Options[name] = value;
+    else
+        cout << "No such option: " << name << endl;
   }
 
 
@@ -227,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);
   }