X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fthread.cpp;h=344cfb794782d7a559194ccf7007645c2bc63bd2;hp=f5aab2b13366e3a3850dfb2979080d489c33b648;hb=f5622cd5ec7836e899e263cc4cd4cc386e1ed5f4;hpb=f6e98a924af233a5e69f3494168cf5d80168c705 diff --git a/src/thread.cpp b/src/thread.cpp index f5aab2b1..344cfb79 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -112,9 +112,9 @@ bool Thread::cutoff_occurred() const { // which are busy searching the split point at the top of slave's split point // stack (the "helpful master concept" in YBWC terminology). -bool Thread::available_to(const Thread* master, bool latejoin) const { +bool Thread::available_to(const Thread* master) const { - if (searching && !latejoin) + if (searching) return false; // Make a local copy to be sure it doesn't become zero under our feet while @@ -181,20 +181,20 @@ void MainThread::idle_loop() { // init() is called at startup to create and launch requested threads, that will -// go immediately to sleep due to 'sleepWhileIdle' set to true. We cannot use -// a c'tor because Threads is a static object and we need a fully initialized -// engine at this point due to allocation of Endgames in Thread c'tor. +// go immediately to sleep. We cannot use a c'tor because Threads is a static +// object and we need a fully initialized engine at this point due to allocation +// of Endgames in Thread c'tor. void ThreadPool::init() { - sleepWhileIdle = true; timer = new_thread(); push_back(new_thread()); read_uci_options(); } -// exit() cleanly terminates the threads before the program exits +// exit() cleanly terminates the threads before the program exits. Cannot be done in +// d'tor because we have to terminate the threads before to free ThreadPool object. void ThreadPool::exit() { @@ -239,7 +239,7 @@ void ThreadPool::read_uci_options() { Thread* ThreadPool::available_slave(const Thread* master) const { for (const_iterator it = begin(); it != end(); ++it) - if ((*it)->available_to(master, false)) + if ((*it)->available_to(master)) return *it; return NULL; @@ -292,7 +292,7 @@ void Thread::split(Position& pos, const Stack* ss, Value alpha, Value beta, Valu Threads.mutex.lock(); sp.mutex.lock(); - sp.allowLatejoin = true; // Only set this under lock protection + sp.allSlavesSearching = true; // Must be set under lock protection ++splitPointsSize; activeSplitPoint = &sp; activePosition = NULL;