summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qmutex_linux.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-08-11 16:45:14 +0200
committerQt by Nokia <qt-info@nokia.com>2012-09-14 03:45:50 +0200
commit30bea611df2d95b53b63273ac867d9bd0a181edf (patch)
tree1d34c3cdf9294d649e02d45a13f46e731b5f9963 /src/corelib/thread/qmutex_linux.cpp
parent870bd84a4ee53ea98fd232da18771b1525dac1a1 (diff)
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 <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/thread/qmutex_linux.cpp')
-rw-r--r--src/corelib/thread/qmutex_linux.cpp20
1 files changed, 6 insertions, 14 deletions
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<QRecursiveMutexPrivate *>(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<QRecursiveMutexPrivate *>(d)->unlock();
+ d_ptr.fetchAndStoreRelease(0);
+ _q_futex(&d_ptr, FUTEX_WAKE, 1, 0);
}