Types of Locks: std::unique_lock
This lesson gives an overview of std::unique_lock which is a type of lock used in C++.
We'll cover the following...
Features
In addition to what’s offered by an std::lock_guard, an std::unique_lock enables us to:
- create it without an associated mutex.
- create it without locking the associated mutex.
- explicitly and repeatedly set or release the lock of the associated mutex.
- move the mutex.
- try to lock the mutex.
- delay the lock on the associated mutex.
Methods
The following table shows the methods of an std::unique_lock lk.
| Method | Description |
|---|---|
lk.lock() |
Locks the associated mutex. |
Ask