summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qmutex.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-08-16 17:15:33 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-05 21:47:09 +0200
commitd84da399649d01ac689e87295f8decc024a4f8e8 (patch)
tree1236b5ebe43e70a25431608091e82fe3ed543d6a /src/corelib/thread/qmutex.h
parent0ebfd0866d7cc9e3dabccf088d8ef1339dfe51a6 (diff)
Use the new 3-operand testAndSet functions in QMutex
This allows us to get the current value of the QMutex / QBasicMutex after the testAndSet operation failed. It saves an extra load from memory. Change-Id: I4922a8b3df15e342b177b13f56cf4f1184314520 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/thread/qmutex.h')
-rw-r--r--src/corelib/thread/qmutex.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index 0bca0def22..0ecc96a9b1 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -86,6 +86,12 @@ private:
inline bool fastTryUnlock() Q_DECL_NOTHROW {
return d_ptr.testAndSetRelease(dummyLocked(), 0);
}
+ inline bool fastTryLock(QMutexData *&current) Q_DECL_NOTHROW {
+ return d_ptr.testAndSetAcquire(0, dummyLocked(), current);
+ }
+ inline bool fastTryUnlock(QMutexData *&current) Q_DECL_NOTHROW {
+ return d_ptr.testAndSetRelease(dummyLocked(), 0, current);
+ }
void lockInternal() QT_MUTEX_LOCK_NOEXCEPT;
bool lockInternal(int timeout) QT_MUTEX_LOCK_NOEXCEPT;