// object for which the thread is the master.
const SplitPoint* sp_master = splitPointsCnt ? curSplitPoint : NULL;
// object for which the thread is the master.
const SplitPoint* sp_master = splitPointsCnt ? curSplitPoint : NULL;
// If this thread is the master of a split point and all slaves have
// finished their work at this split point, return from the idle loop.
// If this thread is the master of a split point and all slaves have
// finished their work at this split point, return from the idle loop.
{
// If we are not searching, wait for a condition to be signaled
// instead of wasting CPU time polling for work.
{
// If we are not searching, wait for a condition to be signaled
// instead of wasting CPU time polling for work.
// particular we need to avoid a deadlock in case a master thread has,
// in the meanwhile, allocated us and sent the wake_up() call before we
// had the chance to grab the lock.
// particular we need to avoid a deadlock in case a master thread has,
// in the meanwhile, allocated us and sent the wake_up() call before we
// had the chance to grab the lock.
sleepCondition.wait(mutex);
mutex.unlock();
}
// If this thread has been assigned work, launch a search
sleepCondition.wait(mutex);
mutex.unlock();
}
// If this thread has been assigned work, launch a search
sp->activePositions[idx] = NULL;
sp->slavesMask &= ~(1ULL << idx);
sp->nodes += pos.nodes_searched();
sp->activePositions[idx] = NULL;
sp->slavesMask &= ~(1ULL << idx);
sp->nodes += pos.nodes_searched();