Rewrite how threads are spawned

Instead of creating a running std::thread and
returning, wait in Thread c'tor that the native
thread of execution goes to sleep in idle_loop().

In this way we can simplify how search is started,
because when main thread is idle we are sure also
all other threads will be idle, in any case, even
at thread creation and startup.

After lazy smp went in, we can simpify and rewrite
a lot of logic that is now no more needed. This is
hopefully the final big cleanup.

Tested for no regression at 5+0.1 with 3 threads:
LLR: 2.95 (-2.94,2.94) [-5.00,0.00]
Total: 17411 W: 3248 L: 3198 D: 10965

No functional change.
This commit is contained in:
Marco Costalba
2015-11-21 07:48:50 +01:00
parent 07e0741dfb
commit 93195555ed
6 changed files with 75 additions and 73 deletions

View File

@@ -170,7 +170,7 @@ void UCI::loop(int argc, char* argv[]) {
|| (token == "ponderhit" && Search::Signals.stopOnPonderhit))
{
Search::Signals.stop = true;
Threads.main()->notify_one(); // Could be sleeping
Threads.main()->start_searching(true); // Could be sleeping
}
else if (token == "ponderhit")
Search::Limits.ponder = 0; // Switch to normal search
@@ -211,7 +211,7 @@ void UCI::loop(int argc, char* argv[]) {
} while (token != "quit" && argc == 1); // Passed args have one-shot behaviour
Threads.main()->join(); // Cannot quit whilst the search is running
Threads.main()->wait_for_search_finished();
}