diff options
author | Darrell Anderson <humanreadable@yahoo.com> | 2012-12-19 14:03:09 -0600 |
---|---|---|
committer | Darrell Anderson <humanreadable@yahoo.com> | 2012-12-19 14:03:09 -0600 |
commit | 35202ed0d899a9ff3c77dad72b501fb30e4dcf93 (patch) | |
tree | 683787f69d937483b860973ce17f0c5d430a142d /src/tools/qmutex_unix.cpp | |
parent | 8d5add0e87ad913bdf0362a83f431995115f3bfa (diff) | |
parent | f19aa203c934d0f85862fdf810a87fe7c5777d17 (diff) | |
download | qt3-35202ed0d899a9ff3c77dad72b501fb30e4dcf93.tar.gz qt3-35202ed0d899a9ff3c77dad72b501fb30e4dcf93.zip |
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/qt3
Diffstat (limited to 'src/tools/qmutex_unix.cpp')
-rw-r--r-- | src/tools/qmutex_unix.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/tools/qmutex_unix.cpp b/src/tools/qmutex_unix.cpp index 7f14e6a..de0f909 100644 --- a/src/tools/qmutex_unix.cpp +++ b/src/tools/qmutex_unix.cpp @@ -74,7 +74,6 @@ typedef pthread_mutex_t Q_MUTEX_T; #include <errno.h> #include <string.h> - // Private class declarations class QRealMutexPrivate : public QMutexPrivate { @@ -86,6 +85,7 @@ public: bool locked(); bool trylock(); int type() const; + int level(); bool recursive; }; @@ -102,6 +102,7 @@ public: bool locked(); bool trylock(); int type() const; + int level(); int count; unsigned long owner; @@ -197,6 +198,11 @@ int QRealMutexPrivate::type() const return recursive ? Q_MUTEX_RECURSIVE : Q_MUTEX_NORMAL; } +int QRealMutexPrivate::level() +{ + return locked(); +} + #ifndef Q_RECURSIVE_MUTEX_TYPE QRecursiveMutexPrivate::QRecursiveMutexPrivate() @@ -330,6 +336,11 @@ int QRecursiveMutexPrivate::type() const return Q_MUTEX_RECURSIVE; } +int QRecursiveMutexPrivate::level() +{ + return count; +} + #endif // !Q_RECURSIVE_MUTEX_TYPE @@ -512,6 +523,22 @@ bool QMutex::tryLock() } /*! + Returns the current lock level of the mutex. + 0 means the mutex is unlocked + This method should only be called when the mutex has already been locked + by lock(), otherwise the lock level could change before the next line + of code is executed. + + WARNING: Non-recursive mutexes will never exceed a lock level of 1! + + \sa lock(), unlock(), locked() +*/ +int QMutex::level() +{ + return d->level(); +} + +/*! \class QMutexLocker qmutex.h \brief The QMutexLocker class simplifies locking and unlocking QMutexes. |