bool available_thread_exists(int master) const;
bool thread_is_available(int slave, int master) const;
bool cutoff_at_splitpoint(int threadID) const;
- void wake_sleeping_thread(int threadID);
void idle_loop(int threadID, SplitPoint* sp);
template <bool Fake>
// Wake up needed threads and reset maxPly counter
for (int i = 0; i < ThreadsMgr.active_threads(); i++)
{
- ThreadsMgr.wake_sleeping_thread(i);
+ ThreadsMgr[i].wake_up();
ThreadsMgr[i].maxPly = 0;
}
// Wake up master thread so to allow it to return from the idle loop in
// case we are the last slave of the split point.
if (useSleepingThreads && threadID != tsp->master && threads[tsp->master].state == THREAD_AVAILABLE)
- wake_sleeping_thread(tsp->master);
+ threads[tsp->master].wake_up();
}
// If this thread is the master of a split point and all slaves have
// Wake up all the threads and waits for termination
for (int i = 1; i < MAX_THREADS; i++)
{
- wake_sleeping_thread(i);
+ threads[i].wake_up();
while (threads[i].state != THREAD_TERMINATED) {}
}
threads[i].state = THREAD_WORKISWAITING; // This makes the slave to exit from idle_loop()
if (useSleepingThreads && i != master)
- wake_sleeping_thread(i);
+ threads[i].wake_up();
}
// Everything is set up. The master thread enters the idle loop, from
}
- // wake_sleeping_thread() wakes up the thread with the given threadID
- // when it is time to start a new search.
-
- void ThreadsManager::wake_sleeping_thread(int threadID) {
-
- lock_grab(&threads[threadID].sleepLock);
- cond_signal(&threads[threadID].sleepCond);
- lock_release(&threads[threadID].sleepLock);
- }
-
-
/// RootMove and RootMoveList method's definitions
RootMove::RootMove() {
SplitPoint* volatile splitPoint;
volatile int activeSplitPoints;
SplitPoint splitPoints[MAX_ACTIVE_SPLIT_POINTS];
+
+ void wake_up() {
+ lock_grab(&sleepLock);
+ cond_signal(&sleepCond);
+ lock_release(&sleepLock);
+ }
};
#endif // !defined(THREAD_H_INCLUDED)