]> git.sesse.net Git - stockfish/commitdiff
Re-add the hack
authorMarco Costalba <mcostalba@gmail.com>
Sun, 13 Jan 2013 22:51:15 +0000 (23:51 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 13 Jan 2013 22:56:04 +0000 (23:56 +0100)
This reverts commit 869c9244101

I misunderstood here. Actually it can happen that
thread is created but still not entered idle_loop
and at the same time start_searching() is called.

Becuase 'do_sleep' is set start_searching() will
set it to false and start the search, but when,
at last, the thread enters idle_loop(), resets
the flag and goes to sleep: not what we want.

Revert the hack waiting for a better solution
in the next patches.

No functional change.

src/thread.cpp

index d674c3ab3f9872635eddd77c7b2d89c65e31cfd9..1f5dc82350e50bdfbcbf0bc578a239d3314b7ea4 100644 (file)
@@ -49,7 +49,8 @@ Thread::Thread(Fn fn) : splitPoints() {
   curSplitPoint = NULL;
   start_fn = fn;
   idx = Threads.size();
-  do_sleep = true;
+
+  do_sleep = (fn != &Thread::main_loop); // Avoid a race with start_searching()
 
   if (!thread_create(handle, start_routine, this))
   {