Boost logo

Boost :

From: Roland Richter (roland_at_[hidden])
Date: 2003-10-27 01:04:01


Dear all,

  the case: I've got a class with a mutex as member, and try
  to find out whether this->mutex is locked or not.

  The following code should find out whether it was locked
  by *another* thread:

   bool locked() const
   {
     Mutex::scoped_try_lock isLocked( mutex, false );
     return !isLocked.try_lock();
   }

  Correct?

  But how to find out whether the mutex was locked by
  the *same* thread? The docs say that a recursice_mutex
  holds some internal lock count - can this be obtained
  from outside?

- Roland


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk