From eb47d241d0212278f54d6f0defdd0ee4d0e4cf63 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Fri, 7 Dec 2012 15:02:42 -0600 Subject: Automated update from Qt3 --- src/tools/qmutex_unix.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/tools/qmutex_unix.cpp') diff --git a/src/tools/qmutex_unix.cpp b/src/tools/qmutex_unix.cpp index 7d22798cc..3fff83366 100644 --- a/src/tools/qmutex_unix.cpp +++ b/src/tools/qmutex_unix.cpp @@ -85,6 +85,7 @@ public: bool locked(); bool trylock(); int type() const; + int level(); bool recursive; }; @@ -101,6 +102,7 @@ public: bool locked(); bool trylock(); int type() const; + int level(); int count; unsigned long owner; @@ -196,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() @@ -329,6 +336,11 @@ int TQRecursiveMutexPrivate::type() const return Q_MUTEX_RECURSIVE; } +int TQRecursiveMutexPrivate::level() +{ + return count; +} + #endif // !Q_RECURSIVE_MUTEX_TYPE @@ -510,6 +522,22 @@ bool TQMutex::tryLock() return d->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. -- cgit v1.2.3