continue;
moveCount = ++splitPoint->moveCount;
- splitPoint->spinlock.release();
+ splitPoint->mutex.unlock();
}
else
++moveCount;
&& moveCount >= FutilityMoveCounts[improving][depth])
{
if (SpNode)
- splitPoint->spinlock.acquire();
+ splitPoint->mutex.lock();
continue;
}
if (SpNode)
{
- splitPoint->spinlock.acquire();
+ splitPoint->mutex.lock();
if (bestValue > splitPoint->bestValue)
splitPoint->bestValue = bestValue;
}
if (predictedDepth < 4 * ONE_PLY && pos.see_sign(move) < VALUE_ZERO)
{
if (SpNode)
- splitPoint->spinlock.acquire();
+ splitPoint->mutex.lock();
continue;
}
// Step 18. Check for new best move
if (SpNode)
{
- splitPoint->spinlock.acquire();
+ splitPoint->mutex.lock();
bestValue = splitPoint->bestValue;
alpha = splitPoint->alpha;
}
// If this thread has been assigned work, launch a search
while (searching)
{
- Threads.spinlock.acquire();
+ Threads.mutex.lock();
assert(activeSplitPoint);
SplitPoint* sp = activeSplitPoint;
- Threads.spinlock.release();
+ Threads.mutex.unlock();
Stack stack[MAX_PLY+4], *ss = stack+2; // To allow referencing (ss-2) and (ss+2)
Position pos(*sp->pos, this);
std::memcpy(ss-2, sp->ss-2, 5 * sizeof(Stack));
ss->splitPoint = sp;
- sp->spinlock.acquire();
+ sp->mutex.lock();
assert(activePosition == nullptr);
// After releasing the lock we can't access any SplitPoint related data
// in a safe way because it could have been released under our feet by
// the sp master.
- sp->spinlock.release();
+ sp->mutex.unlock();
// Try to late join to another split point if none of its slaves has
// already finished.
if ( sp
&& sp->allSlavesSearching
&& sp->slavesMask.count() < MAX_SLAVES_PER_SPLITPOINT
- && available_to(sp->master))
+ && can_join(sp))
{
assert(this != th);
assert(!(this_sp && this_sp->slavesMask.none()));
sp = bestSp;
// Recheck the conditions under lock protection
- Threads.spinlock.acquire();
- sp->spinlock.acquire();
+ Threads.mutex.lock();
+ sp->mutex.lock();
if ( sp->allSlavesSearching
&& sp->slavesMask.count() < MAX_SLAVES_PER_SPLITPOINT
- && available_to(sp->master))
+ && can_join(sp))
{
sp->slavesMask.set(idx);
activeSplitPoint = sp;
searching = true;
}
- sp->spinlock.release();
- Threads.spinlock.release();
+ sp->mutex.unlock();
+ Threads.mutex.unlock();
}
}
// Avoid races with notify_one() fired from last slave of the split point
- std::unique_lock<std::mutex> lk(mutex);
+ std::unique_lock<Mutex> lk(mutex);
// If we are master and all slaves have finished then exit idle_loop
if (this_sp && this_sp->slavesMask.none())
else if (Limits.nodes)
{
- Threads.spinlock.acquire();
+ Threads.mutex.lock();
int64_t nodes = RootPos.nodes_searched();
{
SplitPoint& sp = th->splitPoints[i];
- sp.spinlock.acquire();
+ sp.mutex.lock();
nodes += sp.nodes;
if (sp.slavesMask.test(idx) && Threads[idx]->activePosition)
nodes += Threads[idx]->activePosition->nodes_searched();
- sp.spinlock.release();
+ sp.mutex.unlock();
}
- Threads.spinlock.release();
+ Threads.mutex.unlock();
if (nodes >= Limits.nodes)
Signals.stop = true;