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