mi::base::Recursive_lock::Block Class Reference
Description
Utility class to acquire a lock that is released by the destructor.
See also:
Public Constructors
- Block( Recursive_lock* lock = 0)
- Constructor. More...
Public Destructors
Public Member Functions
- void release()
- Releases the lock. More...
- void set( Recursive_lock* lock)
- Acquires a lock. More...
- bool try_set( Recursive_lock* lock)
- Tries to acquire a lock. More...
Constructors
- mi::base::Recursive_lock::Block::Block( Recursive_lock* lock = 0) [explicit]
-
Constructor.
Parameters
- lock
- If not NULL, this lock is acquired. If NULL, set() can be used to explicitly acquire a lock later.
Destructors
- mi::base::Recursive_lock::Block::~Block()
-
Destructor. Releases the lock (if it is acquired).
Member Functions
- void mi::base::Recursive_lock::Block::release()
-
Releases the lock. Useful to release the lock before the destructor is called.
- void mi::base::Recursive_lock::Block::set( Recursive_lock* lock)
-
Acquires a lock. Releases the current lock (if it is set) and acquires the given lock. Useful to acquire a different lock, or to acquire a lock if no lock was acquired in the constructor.
This method does nothing if the passed lock is already acquired by this class.
Parameters
- lock
- The new lock to acquire.
- bool mi::base::Recursive_lock::Block::try_set( Recursive_lock* lock)
-
Tries to acquire a lock. Releases the current lock (if it is set) and tries to acquire the given lock. Useful to acquire a different lock without blocking, or to acquire a lock without blocking if no lock was acquired in the constructor.
This method does nothing if the passed lock is already acquired by this class.
Parameters
- lock
- The new lock to acquire.
Returns
true if the lock was acquired, false otherwise.