diff options
author | Olivier Goffart <ogoffart@kde.org> | 2011-10-28 11:51:06 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-31 12:14:04 +0100 |
commit | 72257f642944a347b806ac34934d0fb8bc472b1c (patch) | |
tree | cf7dcd30be1b442e8d8dcc1afc5a0befbfc0d09f /src | |
parent | 3c0a26b79f4ab8a20ac385c1f885ee18156a6555 (diff) |
Rename QBasicMutex::d to QBasicMutex::d_ptr
Because we use d as a local variable.
We used this->d to refer it, but this can be confusing to have twice the same
name
Change-Id: I570aa5f444ada358eb456d6b3d9b8bfa60b10bbf
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/thread/qmutex.cpp | 30 | ||||
-rw-r--r-- | src/corelib/thread/qmutex.h | 8 | ||||
-rw-r--r-- | src/corelib/thread/qmutex_linux.cpp | 14 |
3 files changed, 26 insertions, 26 deletions
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index 959d1f958a..88aee2b4c9 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -140,7 +140,7 @@ QT_BEGIN_NAMESPACE */ QMutex::QMutex(RecursionMode mode) { - d.store(mode == Recursive ? new QRecursiveMutexPrivate : 0); + d_ptr.store(mode == Recursive ? new QRecursiveMutexPrivate : 0); } /*! @@ -151,10 +151,10 @@ QMutex::QMutex(RecursionMode mode) QMutex::~QMutex() { if (isRecursive()) - delete static_cast<QRecursiveMutexPrivate *>(d.load()); - else if (d.load()) { + delete static_cast<QRecursiveMutexPrivate *>(d_ptr.load()); + else if (d_ptr.load()) { #ifndef Q_OS_LINUX - if (d.load()->possiblyUnlocked.load() && tryLock()) { unlock(); return; } + if (d_ptr.load()->possiblyUnlocked.load() && tryLock()) { unlock(); return; } #endif qWarning("QMutex: destroying locked mutex"); } @@ -233,7 +233,7 @@ QMutex::~QMutex() */ bool QBasicMutex::isRecursive() { - QMutexPrivate *d = this->d.load(); + QMutexPrivate *d = d_ptr.load(); if (quintptr(d) <= 0x3) return false; return d->recursive; @@ -342,7 +342,7 @@ bool QBasicMutex::isRecursive() { bool QBasicMutex::lockInternal(int timeout) { while (!fastTryLock()) { - QMutexPrivate *d = this->d.loadAcquire(); + QMutexPrivate *d = d_ptr.loadAcquire(); if (!d) // if d is 0, the mutex is unlocked continue; @@ -350,7 +350,7 @@ bool QBasicMutex::lockInternal(int timeout) if (timeout == 0) return false; QMutexPrivate *newD = QMutexPrivate::allocate(); - if (!this->d.testAndSetOrdered(d, newD)) { + if (!d_ptr.testAndSetOrdered(d, newD)) { //Either the mutex is already unlocked, or another thread already set it. newD->deref(); continue; @@ -367,7 +367,7 @@ bool QBasicMutex::lockInternal(int timeout) if (!d->ref()) continue; //that QMutexPrivate was already released - if (d != this->d.loadAcquire()) { + if (d != d_ptr.loadAcquire()) { //Either the mutex is already unlocked, or relocked with another mutex d->deref(); continue; @@ -379,14 +379,14 @@ bool QBasicMutex::lockInternal(int timeout) 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() - if (this->d.testAndSetAcquire(d, dummyLocked())) { + if (d_ptr.testAndSetAcquire(d, dummyLocked())) { // Mutex aquired Q_ASSERT(d->waiters.load() == -QMutexPrivate::BigNumber || d->waiters.load() == 0); d->waiters = 0; d->deref(); return true; } else { - Q_ASSERT(d != this->d.load()); //else testAndSetAcquire should have succeeded + Q_ASSERT(d != d_ptr.load()); //else testAndSetAcquire should have succeeded // Mutex is likely to bo 0, we should continue the outer-loop, // set old_waiters to the magic value of BigNumber old_waiters = QMutexPrivate::BigNumber; @@ -395,7 +395,7 @@ bool QBasicMutex::lockInternal(int timeout) } } while (!d->waiters.testAndSetRelaxed(old_waiters, old_waiters + 1)); - if (d != this->d.loadAcquire()) { + if (d != d_ptr.loadAcquire()) { // Mutex was unlocked. if (old_waiters != QMutexPrivate::BigNumber) { //we did not break the previous loop @@ -411,7 +411,7 @@ bool QBasicMutex::lockInternal(int timeout) d->deref(); d->derefWaiters(1); //we got the lock. (do not deref) - Q_ASSERT(d == this->d.load()); + Q_ASSERT(d == d_ptr.load()); return true; } else { Q_ASSERT(timeout >= 0); @@ -424,7 +424,7 @@ bool QBasicMutex::lockInternal(int timeout) return false; } } - Q_ASSERT(this->d.load() != 0); + Q_ASSERT(d_ptr.load() != 0); return true; } @@ -433,7 +433,7 @@ bool QBasicMutex::lockInternal(int timeout) */ void QBasicMutex::unlockInternal() { - QMutexPrivate *d = this->d.loadAcquire(); + QMutexPrivate *d = d_ptr.loadAcquire(); Q_ASSERT(d); //we must be locked Q_ASSERT(d != dummyLocked()); // testAndSetRelease(dummyLocked(), 0) failed @@ -444,7 +444,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_ptr.testAndSetRelease(d, 0)) { if (d->possiblyUnlocked.load() && d->possiblyUnlocked.testAndSetRelaxed(true, false)) d->deref(); } diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index 4bc2c87cda..2342892a94 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -65,8 +65,8 @@ public: } inline void unlock() { - Q_ASSERT(d.load()); //mutex must be locked - if (!d.testAndSetRelease(dummyLocked(), 0)) + Q_ASSERT(d_ptr.load()); //mutex must be locked + if (!d_ptr.testAndSetRelease(dummyLocked(), 0)) unlockInternal(); } @@ -78,12 +78,12 @@ public: private: inline bool fastTryLock() { - return d.testAndSetAcquire(0, dummyLocked()); + return d_ptr.testAndSetAcquire(0, dummyLocked()); } bool lockInternal(int timeout = -1); void unlockInternal(); - QBasicAtomicPointer<QMutexPrivate> d; + QBasicAtomicPointer<QMutexPrivate> d_ptr; static inline QMutexPrivate *dummyLocked() { return reinterpret_cast<QMutexPrivate *>(quintptr(1)); } diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp index a3ca150a31..3e5b5f2f0d 100644 --- a/src/corelib/thread/qmutex_linux.cpp +++ b/src/corelib/thread/qmutex_linux.cpp @@ -82,14 +82,14 @@ bool QBasicMutex::lockInternal(int timeout) elapsedTimer.start(); while (!fastTryLock()) { - QMutexPrivate *d = this->d.load(); + QMutexPrivate *d = d_ptr.load(); if (!d) // if d is 0, the mutex is unlocked continue; if (quintptr(d) <= 0x3) { //d == dummyLocked() || d == dummyFutexValue() if (timeout == 0) return false; - while (this->d.fetchAndStoreAcquire(dummyFutexValue()) != 0) { + while (d_ptr.fetchAndStoreAcquire(dummyFutexValue()) != 0) { struct timespec ts, *pts = 0; if (timeout >= 1) { // recalculate the timeout @@ -103,7 +103,7 @@ bool QBasicMutex::lockInternal(int timeout) ts.tv_nsec = xtimeout % (Q_INT64_C(1000) * 1000 * 1000); pts = &ts; } - int r = _q_futex(&this->d, FUTEX_WAIT, quintptr(dummyFutexValue()), pts); + int r = _q_futex(&d_ptr, FUTEX_WAIT, quintptr(dummyFutexValue()), pts); if (r != 0 && errno == ETIMEDOUT) return false; } @@ -112,19 +112,19 @@ bool QBasicMutex::lockInternal(int timeout) Q_ASSERT(d->recursive); return static_cast<QRecursiveMutexPrivate *>(d)->lock(timeout); } - Q_ASSERT(this->d.load()); + Q_ASSERT(d_ptr.load()); return true; } void QBasicMutex::unlockInternal() { - QMutexPrivate *d = this->d.load(); + QMutexPrivate *d = d_ptr.load(); Q_ASSERT(d); //we must be locked Q_ASSERT(d != dummyLocked()); // testAndSetRelease(dummyLocked(), 0) failed if (d == dummyFutexValue()) { - this->d.fetchAndStoreRelease(0); - _q_futex(&this->d, FUTEX_WAKE, 1, 0); + d_ptr.fetchAndStoreRelease(0); + _q_futex(&d_ptr, FUTEX_WAKE, 1, 0); return; } |