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:
paulc 2005-02-28 08:25:41 +00:00
parent 8f630fea09
commit 9ed8a01410
2 changed files with 14 additions and 0 deletions

View File

@ -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;

View File

@ -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