diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-08-11 16:45:14 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-09-14 03:45:50 +0200 |
commit | 30bea611df2d95b53b63273ac867d9bd0a181edf (patch) | |
tree | 1d34c3cdf9294d649e02d45a13f46e731b5f9963 /src/corelib/thread/qmutex.h | |
parent | 870bd84a4ee53ea98fd232da18771b1525dac1a1 (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.h')
-rw-r--r-- | src/corelib/thread/qmutex.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index 5d4d6969f5..dd718c4796 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -71,7 +71,7 @@ public: inline void unlock() Q_DECL_NOTHROW { Q_ASSERT(d_ptr.load()); //mutex must be locked - if (!d_ptr.testAndSetRelease(dummyLocked(), 0)) + if (!fastTryUnlock()) unlockInternal(); } @@ -85,6 +85,10 @@ private: inline bool fastTryLock() Q_DECL_NOTHROW { return d_ptr.testAndSetAcquire(0, dummyLocked()); } + inline bool fastTryUnlock() Q_DECL_NOTHROW { + return d_ptr.testAndSetRelease(dummyLocked(), 0); + } + bool lockInternal(int timeout = -1) QT_MUTEX_LOCK_NOEXCEPT; void unlockInternal() Q_DECL_NOTHROW; |