diff options
| author | Darrell Anderson <humanreadable@yahoo.com> | 2012-12-19 14:03:14 -0600 |
|---|---|---|
| committer | Darrell Anderson <humanreadable@yahoo.com> | 2012-12-19 14:03:14 -0600 |
| commit | f8224f3a623495e4e1dbf852554d7601a6b7c4c4 (patch) | |
| tree | d5583114ba48669960c9f7d68927687ea652a0b8 /src/tools/qmutex_unix.cpp | |
| parent | 25240579092616b09d28705ac84e13e49b744707 (diff) | |
| parent | e8cbbedf46da493d2c206444a7e18e5777402905 (diff) | |
| download | tqt-f8224f3a623495e4e1dbf852554d7601a6b7c4c4.tar.gz tqt-f8224f3a623495e4e1dbf852554d7601a6b7c4c4.zip | |
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/tqt3
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 b69661ad1..3fff83366 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 TQRealMutexPrivate : public TQMutexPrivate { @@ -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 TQRealMutexPrivate::type() const return recursive ? Q_MUTEX_RECURSIVE : Q_MUTEX_NORMAL; } +int TQRealMutexPrivate::level() +{ + return locked(); +} + #ifndef Q_RECURSIVE_MUTEX_TYPE TQRecursiveMutexPrivate::TQRecursiveMutexPrivate() @@ -330,6 +336,11 @@ int TQRecursiveMutexPrivate::type() const return Q_MUTEX_RECURSIVE; } +int TQRecursiveMutexPrivate::level() +{ + return count; +} + #endif // !Q_RECURSIVE_MUTEX_TYPE @@ -512,6 +523,22 @@ bool TQMutex::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 TQMutex::level() +{ + return d->level(); +} + +/*! \class TQMutexLocker ntqmutex.h \brief The TQMutexLocker class simplifies locking and unlocking TQMutexes. |
