From 30bea611df2d95b53b63273ac867d9bd0a181edf Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 11 Aug 2012 16:45:14 +0200 Subject: Make QBasicMutex be exclusively non-recursive Dispatch to the recursive mutex functions from QMutex::lock, tryLock and unlock. This has the benefit that those using QBasicMutex will not go through the testing for recursive mutexes. It simplifies a little the code for those users. For the users of QMutex, the code required to perform a lock does not appear to change. Change-Id: I0ca9965e012b283c30f1fab8e9f6d9b3288c2247 Reviewed-by: Lars Knoll --- src/corelib/thread/qmutex_linux.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/corelib/thread/qmutex_linux.cpp') diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp index 09db046f0f..a17e9d0a24 100644 --- a/src/corelib/thread/qmutex_linux.cpp +++ b/src/corelib/thread/qmutex_linux.cpp @@ -116,13 +116,9 @@ static inline QMutexData *dummyFutexValue() bool QBasicMutex::lockInternal(int timeout) Q_DECL_NOTHROW { - // we're here because fastTryLock() has just failed - QMutexData *d = d_ptr.load(); - if (quintptr(d) > 0x3) { //d == dummyLocked() || d == dummyFutexValue() - Q_ASSERT(d->recursive); - return static_cast(d)->lock(timeout); - } + Q_ASSERT(!isRecursive()); + // we're here because fastTryLock() has just failed if (timeout == 0) return false; @@ -167,15 +163,11 @@ void QBasicMutex::unlockInternal() Q_DECL_NOTHROW QMutexData *d = d_ptr.load(); Q_ASSERT(d); //we must be locked Q_ASSERT(d != dummyLocked()); // testAndSetRelease(dummyLocked(), 0) failed + Q_UNUSED(d); + Q_ASSERT(!isRecursive()); - if (d == dummyFutexValue()) { - d_ptr.fetchAndStoreRelease(0); - _q_futex(&d_ptr, FUTEX_WAKE, 1, 0); - return; - } - - Q_ASSERT(d->recursive); - static_cast(d)->unlock(); + d_ptr.fetchAndStoreRelease(0); + _q_futex(&d_ptr, FUTEX_WAKE, 1, 0); } -- cgit v1.2.3