summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2012-12-07 15:02:42 -0600
committerTimothy Pearson <[email protected]>2012-12-07 15:02:42 -0600
commiteb47d241d0212278f54d6f0defdd0ee4d0e4cf63 (patch)
treeda8c74a9fe8d66193441c567c5ee3c13d63a350d /src/tools
parent9ee8babab368f8262ff21530d0cf23d898fbe857 (diff)
downloadtqt3-eb47d241d0212278f54d6f0defdd0ee4d0e4cf63.tar.gz
tqt3-eb47d241d0212278f54d6f0defdd0ee4d0e4cf63.zip
Automated update from Qt3
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/ntqmutex.h3
-rw-r--r--src/tools/qmutex_p.h1
-rw-r--r--src/tools/qmutex_unix.cpp28
3 files changed, 32 insertions, 0 deletions
diff --git a/src/tools/ntqmutex.h b/src/tools/ntqmutex.h
index 2a9afb1d2..7b73514da 100644
--- a/src/tools/ntqmutex.h
+++ b/src/tools/ntqmutex.h
@@ -74,6 +74,9 @@ private:
TQMutex( const TQMutex & );
TQMutex &operator=( const TQMutex & );
#endif
+
+public:
+ int level();
};
class Q_EXPORT TQMutexLocker
diff --git a/src/tools/qmutex_p.h b/src/tools/qmutex_p.h
index 7650cee8b..3e9de8e5c 100644
--- a/src/tools/qmutex_p.h
+++ b/src/tools/qmutex_p.h
@@ -67,6 +67,7 @@ public:
virtual bool locked() = 0;
virtual bool trylock() = 0;
virtual int type() const = 0;
+ virtual int level() = 0;
};
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
@@ -511,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.