- main.do_sleep = false;
- cond_signal(main.sleepCond); // Wake up main thread and start searching
-
- if (!async)
- while (!main.do_sleep)
- 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. We cannot return before
-// main has finished to avoid a crash in case of a 'quit' command.
-
-void ThreadsManager::stop_thinking() {
-
- Thread& main = *threads.front();
-
- 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);