From d84da399649d01ac689e87295f8decc024a4f8e8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Aug 2012 17:15:33 +0200 Subject: 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 --- src/corelib/thread/qmutex.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/corelib/thread/qmutex.h') 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 *¤t) Q_DECL_NOTHROW { + return d_ptr.testAndSetAcquire(0, dummyLocked(), current); + } + inline bool fastTryUnlock(QMutexData *¤t) Q_DECL_NOTHROW { + return d_ptr.testAndSetRelease(dummyLocked(), 0, current); + } void lockInternal() QT_MUTEX_LOCK_NOEXCEPT; bool lockInternal(int timeout) QT_MUTEX_LOCK_NOEXCEPT; -- cgit v1.2.3