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:
parent
64e3629cdf
commit
8f89bbaf8e
@ -201,6 +201,7 @@ Q_NEVER_INLINE static bool contendedTryLockForRead(QAtomicPointer<QReadWriteLock
|
|||||||
QDeadlineTimer timeout, QReadWriteLockPrivate *d)
|
QDeadlineTimer timeout, QReadWriteLockPrivate *d)
|
||||||
{
|
{
|
||||||
while (true) {
|
while (true) {
|
||||||
|
qYieldCpu();
|
||||||
if (d == nullptr) {
|
if (d == nullptr) {
|
||||||
if (fastTryLock(d_ptr, dummyLockedForRead, d))
|
if (fastTryLock(d_ptr, dummyLockedForRead, d))
|
||||||
return true;
|
return true;
|
||||||
@ -318,6 +319,7 @@ Q_NEVER_INLINE static bool contendedTryLockForWrite(QAtomicPointer<QReadWriteLoc
|
|||||||
QDeadlineTimer timeout, QReadWriteLockPrivate *d)
|
QDeadlineTimer timeout, QReadWriteLockPrivate *d)
|
||||||
{
|
{
|
||||||
while (true) {
|
while (true) {
|
||||||
|
qYieldCpu();
|
||||||
if (d == nullptr) {
|
if (d == nullptr) {
|
||||||
if (fastTryLock(d_ptr, dummyLockedForWrite, d))
|
if (fastTryLock(d_ptr, dummyLockedForWrite, d))
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user