@ -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 QRealMutexPrivate::type() const
return recursive ? Q_MUTEX_RECURSIVE : Q_MUTEX_NORMAL ;
}
int QRealMutexPrivate : : level ( )
{
return locked ( ) ;
}
# ifndef Q_RECURSIVE_MUTEX_TYPE
QRecursiveMutexPrivate : : QRecursiveMutexPrivate ( )
@ -329,6 +336,11 @@ int QRecursiveMutexPrivate::type() const
return Q_MUTEX_RECURSIVE ;
}
int QRecursiveMutexPrivate : : level ( )
{
return count ;
}
# endif // !Q_RECURSIVE_MUTEX_TYPE
@ -510,6 +522,22 @@ bool QMutex::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 QMutex : : level ( )
{
return d - > level ( ) ;
}
/*!
\ class QMutexLocker qmutex . h
\ brief The QMutexLocker class simplifies locking and unlocking QMutexes .