diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2010-10-01 07:44:55 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2010-12-20 15:49:39 (GMT) |
commit | feb0b0cd47808a77a048c6a13686d39a0540a488 (patch) | |
tree | c4ef4eaf2250300ae7bf019d6717c1baa902a0fc | |
parent | d9e35493d494df60d771a928a8d0dbde2b66906e (diff) | |
download | Qt-feb0b0cd47808a77a048c6a13686d39a0540a488.zip Qt-feb0b0cd47808a77a048c6a13686d39a0540a488.tar.gz Qt-feb0b0cd47808a77a048c6a13686d39a0540a488.tar.bz2 |
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
-rw-r--r-- | src/corelib/thread/qmutex.cpp | 15 |
1 files 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; |