From feb0b0cd47808a77a048c6a13686d39a0540a488 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 1 Oct 2010 09:44:55 +0200 Subject: Remove unnecessary testAndSetAcquire from QMutex::lockInternal() QMutexPrivate::wait() will take care of doing another test for the lock before putting the thread to sleep, so we can avoid another if(). Reviewed-by: joao --- src/corelib/thread/qmutex.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index 403468a..19e2457 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -437,15 +437,12 @@ void QMutex::lockInternal() do { if (spinCount++ > maximumSpinCount) { - // puts("spinning useless, sleeping"); - bool isLocked = d->contenders.testAndSetAcquire(0, 1); - if (!isLocked) { - - // didn't get the lock, wait for it - isLocked = d->wait(); - Q_ASSERT_X(isLocked, "QMutex::lock", - "Internal error, infinite wait has timed out."); - } + // didn't get the lock, wait for it + bool isLocked = d->wait(); + Q_ASSERT_X(isLocked, "QMutex::lock", + "Internal error, infinite wait has timed out."); + Q_UNUSED(isLocked); + // decrease the lastSpinCount since we didn't actually get the lock by spinning spinCount = -d->lastSpinCount / SpinCountPenalizationDivisor; break; -- cgit v0.12