diff options
author | Liang Qi <liang.qi@qt.io> | 2017-03-02 09:04:38 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-03-02 09:04:38 +0100 |
commit | 71264bae08d81bdeceb96133fdb01c370504dfcc (patch) | |
tree | d5dadaac8209d5ef1857a4d65197b9ee12b39848 /src/corelib/thread | |
parent | 5e785c0b83c9908c665f253c131629ac325a21f5 (diff) | |
parent | 6d10f739cd750968d0dd0e9d8fa4b64353a86c6c (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: I84097f8e7b3b2128028bd7693c913d6968b82bfe
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qreadwritelock.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/thread/qreadwritelock.cpp b/src/corelib/thread/qreadwritelock.cpp index 6302a3a515..42befc4b80 100644 --- a/src/corelib/thread/qreadwritelock.cpp +++ b/src/corelib/thread/qreadwritelock.cpp @@ -392,13 +392,13 @@ bool QReadWriteLock::tryLockForWrite(int timeout) */ void QReadWriteLock::unlock() { - QReadWriteLockPrivate *d = d_ptr.load(); + QReadWriteLockPrivate *d = d_ptr.loadAcquire(); while (true) { Q_ASSERT_X(d, "QReadWriteLock::unlock()", "Cannot unlock an unlocked lock"); // Fast case: no contention: (no waiters, no other readers) if (quintptr(d) <= 2) { // 1 or 2 (StateLockedForRead or StateLockedForWrite) - if (!d_ptr.testAndSetRelease(d, nullptr, d)) + if (!d_ptr.testAndSetOrdered(d, nullptr, d)) continue; return; } @@ -407,7 +407,7 @@ void QReadWriteLock::unlock() Q_ASSERT(quintptr(d) > (1U<<4)); //otherwise that would be the fast case // Just decrease the reader's count. auto val = reinterpret_cast<QReadWriteLockPrivate *>(quintptr(d) - (1U<<4)); - if (!d_ptr.testAndSetRelease(d, val, d)) + if (!d_ptr.testAndSetOrdered(d, val, d)) continue; return; } |