diff options
| author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2011-09-29 11:50:08 +0200 |
|---|---|---|
| committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-27 18:57:38 +0200 |
| commit | 6476ac738ca029af95932f53b53f0705808eb80e (patch) | |
| tree | d1884397040eb65d23a48a0e1a56dad3f476cf34 /src/corelib/thread/qmutex.cpp | |
| parent | 434824aede28e8c36d6991aa218f89daf2cc22fa (diff) | |
Replace implicit QAtomic* casts with explicit load()/store()
Change-Id: Ia7ef1a8e01001f203e409c710c977d6f4686342e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/thread/qmutex.cpp')
| -rw-r--r-- | src/corelib/thread/qmutex.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index e2da0adf177..959d1f958ae 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -154,7 +154,7 @@ QMutex::~QMutex() delete static_cast<QRecursiveMutexPrivate *>(d.load()); else if (d.load()) { #ifndef Q_OS_LINUX - if (d.load()->possiblyUnlocked && tryLock()) { unlock(); return; } + if (d.load()->possiblyUnlocked.load() && tryLock()) { unlock(); return; } #endif qWarning("QMutex: destroying locked mutex"); } @@ -361,7 +361,7 @@ bool QBasicMutex::lockInternal(int timeout) return static_cast<QRecursiveMutexPrivate *>(d)->lock(timeout); } - if (timeout == 0 && !d->possiblyUnlocked) + if (timeout == 0 && !d->possiblyUnlocked.load()) return false; if (!d->ref()) @@ -375,7 +375,7 @@ bool QBasicMutex::lockInternal(int timeout) int old_waiters; do { - old_waiters = d->waiters; + old_waiters = d->waiters.load(); if (old_waiters == -QMutexPrivate::BigNumber) { // we are unlocking, and the thread that unlocks is about to change d to 0 // we try to aquire the mutex by changing to dummyLocked() @@ -407,7 +407,7 @@ bool QBasicMutex::lockInternal(int timeout) } if (d->wait(timeout)) { - if (d->possiblyUnlocked && d->possiblyUnlocked.testAndSetRelaxed(true, false)) + if (d->possiblyUnlocked.load() && d->possiblyUnlocked.testAndSetRelaxed(true, false)) d->deref(); d->derefWaiters(1); //we got the lock. (do not deref) @@ -445,7 +445,7 @@ void QBasicMutex::unlockInternal() if (d->waiters.fetchAndAddRelease(-QMutexPrivate::BigNumber) == 0) { //there is no one waiting on this mutex anymore, set the mutex as unlocked (d = 0) if (this->d.testAndSetRelease(d, 0)) { - if (d->possiblyUnlocked && d->possiblyUnlocked.testAndSetRelaxed(true, false)) + if (d->possiblyUnlocked.load() && d->possiblyUnlocked.testAndSetRelaxed(true, false)) d->deref(); } d->derefWaiters(0); @@ -479,10 +479,10 @@ QMutexPrivate *QMutexPrivate::allocate() int i = freelist()->next(); QMutexPrivate *d = &(*freelist())[i]; d->id = i; - Q_ASSERT(d->refCount == 0); + Q_ASSERT(d->refCount.load() == 0); Q_ASSERT(!d->recursive); - Q_ASSERT(!d->possiblyUnlocked); - Q_ASSERT(d->waiters == 0); + Q_ASSERT(!d->possiblyUnlocked.load()); + Q_ASSERT(d->waiters.load() == 0); d->refCount = 1; return d; } @@ -490,9 +490,9 @@ QMutexPrivate *QMutexPrivate::allocate() void QMutexPrivate::release() { Q_ASSERT(!recursive); - Q_ASSERT(refCount == 0); - Q_ASSERT(!possiblyUnlocked); - Q_ASSERT(waiters == 0); + Q_ASSERT(refCount.load() == 0); + Q_ASSERT(!possiblyUnlocked.load()); + Q_ASSERT(waiters.load() == 0); freelist()->release(id); } @@ -502,7 +502,7 @@ void QMutexPrivate::derefWaiters(int value) int old_waiters; int new_waiters; do { - old_waiters = waiters; + old_waiters = waiters.load(); new_waiters = old_waiters; if (new_waiters < 0) { new_waiters += QMutexPrivate::BigNumber; |
