- SearchMoves = searchMoves;
-
- // Reset signals before to start the new search
- memset((void*)&Signals, 0, sizeof(Signals));
-
- main.do_sleep = false;
- cond_signal(&main.sleepCond); // Wake up main thread and start searching
-
- if (!asyncMode)
- cond_wait(&sleepCond, &main.sleepLock);
-
- lock_release(&main.sleepLock);
-}
-
-
-// ThreadsManager::stop_thinking() is used by UI thread to raise a stop request
-// and to wait for the main thread finishing the search. Needed to wait exiting
-// and terminate the threads after a 'quit' command.
-
-void ThreadsManager::stop_thinking() {
-
- Thread& main = threads[0];
-
- Search::Signals.stop = true;
-
- lock_grab(&main.sleepLock);
-
- cond_signal(&main.sleepCond); // In case is waiting for stop or ponderhit
-
- while (!main.do_sleep)
- cond_wait(&sleepCond, &main.sleepLock);
-
- lock_release(&main.sleepLock);
-}
-
-
-// ThreadsManager::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
-// then return, after which the bestmove and pondermove will be printed.
-
-void ThreadsManager::wait_for_stop_or_ponderhit() {
-
- Signals.stopOnPonderhit = true;
-
- Thread& main = threads[0];
-
- lock_grab(&main.sleepLock);