Introduce and use wait_for_search_finished()

Helper function that allows us to simplify
the code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2012-03-26 17:19:37 +02:00
parent 32d3a07c67
commit 3aa471f2a9
4 changed files with 35 additions and 51 deletions

View 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);
}