QReadWriteLock: add qYieldCpu() calls to the contended loop acquisitions

We're looping on fastTryLock() (which does testAndSetAcquire()) and a
few other testAndSet()s, so we should yield the CPU between
calls.

Change-Id: I6ba01efc9142f8be2bf1fffddf06c027dde18016
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
Thiago Macieira 2025-04-09 12:09:52 -07:00
parent 64e3629cdf
commit 8f89bbaf8e

View File

@ -201,6 +201,7 @@ Q_NEVER_INLINE static bool contendedTryLockForRead(QAtomicPointer<QReadWriteLock
QDeadlineTimer timeout, QReadWriteLockPrivate *d)
{
while (true) {
qYieldCpu();
if (d == nullptr) {
if (fastTryLock(d_ptr, dummyLockedForRead, d))
return true;
@ -318,6 +319,7 @@ Q_NEVER_INLINE static bool contendedTryLockForWrite(QAtomicPointer<QReadWriteLoc
QDeadlineTimer timeout, QReadWriteLockPrivate *d)
{
while (true) {
qYieldCpu();
if (d == nullptr) {
if (fastTryLock(d_ptr, dummyLockedForWrite, d))
return true;