From 89a89eb60535a72139730ecd60b6e1257db269d4 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 13 Jan 2013 14:15:19 +0100 Subject: [PATCH] Simplify and rename wait_for_stop_or_ponderhit() Setting stopOnPonderhit is now done by the caller. No functional change. --- src/search.cpp | 5 ++++- src/thread.cpp | 14 ++++++-------- src/thread.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index b3f66c6a..1371d1b9 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -265,7 +265,10 @@ finalize: // but if we are pondering or in infinite search, we shouldn't print the best // move before we are told to do so. if (!Signals.stop && (Limits.ponder || Limits.infinite)) - RootPos.this_thread()->wait_for_stop_or_ponderhit(); + { + Signals.stopOnPonderhit = true; + RootPos.this_thread()->wait_for_stop(); + } // Best move could be MOVE_NONE when searching on a stalemate position sync_cout << "bestmove " << move_to_uci(RootMoves[0].pv[0], RootPos.is_chess960()) diff --git a/src/thread.cpp b/src/thread.cpp index b5999605..180869c6 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -131,16 +131,14 @@ void Thread::wake_up() { } -// Thread::wait_for_stop_or_ponderhit() is called when the maximum depth is -// reached while the program is pondering. The point is to work around a wrinkle -// in the UCI protocol: When pondering, the engine is not allowed to give a -// "bestmove" before the GUI sends it a "stop" or "ponderhit" command. We simply -// wait here until one of these commands (that raise StopRequest) is sent and +// Thread::wait_for_stop() is called when the maximum depth is reached while +// the program is pondering. The point is to work around a wrinkle in the UCI +// protocol: When pondering, the engine is not allowed to give a "bestmove" +// before the GUI sends it a "stop" or "ponderhit" command. We simply wait here +// until one of these commands (that raise Signals.stop) is sent and // then return, after which the bestmove and pondermove will be printed. -void Thread::wait_for_stop_or_ponderhit() { - - Signals.stopOnPonderhit = true; +void Thread::wait_for_stop() { mutex.lock(); while (!Signals.stop) sleepCondition.wait(mutex); diff --git a/src/thread.h b/src/thread.h index 2d8a675b..92be3a22 100644 --- a/src/thread.h +++ b/src/thread.h @@ -105,7 +105,7 @@ public: void idle_loop(); void main_loop(); void timer_loop(); - void wait_for_stop_or_ponderhit(); + void wait_for_stop(); SplitPoint splitPoints[MAX_SPLITPOINTS_PER_THREAD]; Material::Table materialTable; -- 2.39.2