mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 00:56:39 +08:00
Use acquire() and release() for spinlocks
It is more idiomatick than lock() and unlock() No functional change.
This commit is contained in:
@@ -826,7 +826,7 @@ moves_loop: // When in check and at SpNode search starts from here
|
||||
continue;
|
||||
|
||||
moveCount = ++splitPoint->moveCount;
|
||||
splitPoint->mutex.unlock();
|
||||
splitPoint->spinlock.release();
|
||||
}
|
||||
else
|
||||
++moveCount;
|
||||
@@ -895,7 +895,7 @@ moves_loop: // When in check and at SpNode search starts from here
|
||||
&& moveCount >= FutilityMoveCounts[improving][depth])
|
||||
{
|
||||
if (SpNode)
|
||||
splitPoint->mutex.lock();
|
||||
splitPoint->spinlock.acquire();
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -914,7 +914,7 @@ moves_loop: // When in check and at SpNode search starts from here
|
||||
|
||||
if (SpNode)
|
||||
{
|
||||
splitPoint->mutex.lock();
|
||||
splitPoint->spinlock.acquire();
|
||||
if (bestValue > splitPoint->bestValue)
|
||||
splitPoint->bestValue = bestValue;
|
||||
}
|
||||
@@ -926,7 +926,7 @@ moves_loop: // When in check and at SpNode search starts from here
|
||||
if (predictedDepth < 4 * ONE_PLY && pos.see_sign(move) < VALUE_ZERO)
|
||||
{
|
||||
if (SpNode)
|
||||
splitPoint->mutex.lock();
|
||||
splitPoint->spinlock.acquire();
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -1026,7 +1026,7 @@ moves_loop: // When in check and at SpNode search starts from here
|
||||
// Step 18. Check for new best move
|
||||
if (SpNode)
|
||||
{
|
||||
splitPoint->mutex.lock();
|
||||
splitPoint->spinlock.acquire();
|
||||
bestValue = splitPoint->bestValue;
|
||||
alpha = splitPoint->alpha;
|
||||
}
|
||||
@@ -1630,7 +1630,7 @@ void Thread::idle_loop() {
|
||||
std::memcpy(ss-2, sp->ss-2, 5 * sizeof(Stack));
|
||||
ss->splitPoint = sp;
|
||||
|
||||
sp->mutex.lock();
|
||||
sp->spinlock.acquire();
|
||||
|
||||
assert(activePosition == nullptr);
|
||||
|
||||
@@ -1659,7 +1659,7 @@ void Thread::idle_loop() {
|
||||
// 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->mutex.unlock();
|
||||
sp->spinlock.release();
|
||||
|
||||
// Try to late join to another split point if none of its slaves has
|
||||
// already finished.
|
||||
@@ -1699,12 +1699,12 @@ void Thread::idle_loop() {
|
||||
sp = bestSp;
|
||||
|
||||
// Recheck the conditions under lock protection
|
||||
sp->mutex.lock();
|
||||
sp->spinlock.acquire();
|
||||
|
||||
if ( sp->allSlavesSearching
|
||||
&& sp->slavesMask.count() < MAX_SLAVES_PER_SPLITPOINT)
|
||||
{
|
||||
allocMutex.lock();
|
||||
spinlock.acquire();
|
||||
|
||||
if (can_join(sp))
|
||||
{
|
||||
@@ -1713,10 +1713,10 @@ void Thread::idle_loop() {
|
||||
searching = true;
|
||||
}
|
||||
|
||||
allocMutex.unlock();
|
||||
spinlock.release();
|
||||
}
|
||||
|
||||
sp->mutex.unlock();
|
||||
sp->spinlock.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1767,7 +1767,7 @@ void check_time() {
|
||||
{
|
||||
SplitPoint& sp = th->splitPoints[i];
|
||||
|
||||
sp.mutex.lock();
|
||||
sp.spinlock.acquire();
|
||||
|
||||
nodes += sp.nodes;
|
||||
|
||||
@@ -1775,7 +1775,7 @@ void check_time() {
|
||||
if (sp.slavesMask.test(idx) && Threads[idx]->activePosition)
|
||||
nodes += Threads[idx]->activePosition->nodes_searched();
|
||||
|
||||
sp.mutex.unlock();
|
||||
sp.spinlock.release();
|
||||
}
|
||||
|
||||
if (nodes >= Limits.nodes)
|
||||
|
||||
Reference in New Issue
Block a user