- protected:
-
- mutex& mutex_;
- bool is_locked_;
-
- friend class condition;
- };
-
- /**
- * This type of lock tries to acquire a lock on the mutex during
- * construction and releases the lock on deconstruction.
- */
- class scoped_lock : private lock
- {
- public:
-
- /**
- * Construct a lock.
- * \param mutex The mutex.
- */
- explicit scoped_lock(mutex& mutex) :
- lock(mutex)
- {
- acquire();
- }
-
- /**
- * Get whether or not the mutex is locked.
- * \return True if the mutex is locked, false otherwise.
- */
- bool is_locked() const
- {
- return lock::is_locked();
- }
- };