else
assert(false);
+ spinlock.acquire();
assert(searching);
searching = false;
// 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.
+ spinlock.release();
sp->spinlock.release();
// Try to late join to another split point if none of its slaves has
SplitPoint& sp = splitPoints[splitPointsSize];
sp.spinlock.acquire(); // No contention here until we don't increment splitPointsSize
+ spinlock.acquire();
sp.master = this;
sp.parentSplitPoint = activeSplitPoint;
++splitPointsSize;
activeSplitPoint = &sp;
activePosition = nullptr;
+ spinlock.release();
// Try to allocate available threads
Thread* slave;
Thread::idle_loop(); // Force a call to base class idle_loop()
+ sp.spinlock.acquire();
+ spinlock.acquire();
+
// In the helpful master concept, a master can help only a sub-tree of its
// split point and because everything is finished here, it's not possible
// for the master to be booked.
// We have returned from the idle loop, which means that all threads are
// finished. Note that decreasing splitPointsSize must be done under lock
// protection to avoid a race with Thread::can_join().
- sp.spinlock.acquire();
-
--splitPointsSize;
activeSplitPoint = sp.parentSplitPoint;
activePosition = &pos;
*bestMove = sp.bestMove;
*bestValue = sp.bestValue;
+ spinlock.release();
sp.spinlock.release();
}