]> git.sesse.net Git - stockfish/blobdiff - src/thread.cpp
Retire set_timer()
[stockfish] / src / thread.cpp
index 712b04a30fa85a625fbc6c4cf80e6b90cd359ce7..d674c3ab3f9872635eddd77c7b2d89c65e31cfd9 100644 (file)
@@ -49,8 +49,7 @@ Thread::Thread(Fn fn) : splitPoints() {
   curSplitPoint = NULL;
   start_fn = fn;
   idx = Threads.size();
-
-  do_sleep = (fn != &Thread::main_loop); // Avoid a race with start_searching()
+  do_sleep = true;
 
   if (!thread_create(handle, start_routine, this))
   {
@@ -81,7 +80,8 @@ void Thread::timer_loop() {
   while (!do_exit)
   {
       mutex.lock();
-      sleepCondition.wait_for(mutex, maxPly ? maxPly : INT_MAX);
+      while (!maxPly && !do_exit)
+          sleepCondition.wait_for(mutex, maxPly ? maxPly : INT_MAX);
       mutex.unlock();
       check_time();
   }
@@ -238,16 +238,6 @@ bool ThreadPool::available_slave_exists(Thread* master) const {
 }
 
 
-// set_timer() is used to set the timer to trigger after msec milliseconds.
-// If msec is 0 then timer is stopped.
-
-void ThreadPool::set_timer(int msec) {
-
-  timer->maxPly = msec;
-  timer->notify_one(); // Wake up and restart the timer
-}
-
-
 // split() does the actual work of distributing the work at a node between
 // several available threads. If it does not succeed in splitting the node
 // (because no idle threads are available, or because we have no unused split