Added fast locked() method to check if a mutex is held.
git-svn-id: http://yate.null.ro/svn/yate/trunk@250 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
8f630fea09
commit
9ed8a01410
|
@ -43,6 +43,8 @@ public:
|
|||
{ if (!--m_refcount) delete this; }
|
||||
inline bool recursive() const
|
||||
{ return m_recursive; }
|
||||
bool locked() const
|
||||
{ return (m_locked > 0); }
|
||||
bool lock(long long int maxwait);
|
||||
void unlock();
|
||||
static volatile int s_count;
|
||||
|
@ -250,6 +252,11 @@ bool Mutex::recursive() const
|
|||
return m_private && m_private->recursive();
|
||||
}
|
||||
|
||||
bool Mutex::locked() const
|
||||
{
|
||||
return m_private && m_private->locked();
|
||||
}
|
||||
|
||||
int Mutex::count()
|
||||
{
|
||||
return MutexPrivate::s_count;
|
||||
|
|
|
@ -1747,6 +1747,13 @@ public:
|
|||
*/
|
||||
void unlock();
|
||||
|
||||
/**
|
||||
* Check if the mutex is currently locked - as it's asynchronous it
|
||||
* guarantees nothing if other thread changes the mutex's status
|
||||
* @return True if the mutex was locked when the function was called
|
||||
*/
|
||||
bool locked() const;
|
||||
|
||||
/**
|
||||
* Check if the mutex is unlocked (try to lock and unlock the mutex)
|
||||
* @param maxait Time in microseconds to wait for the mutex, -1 wait forever
|
||||
|
|
Loading…
Reference in New Issue