[thread.lock.general] (original) (raw)
32 Concurrency support library [thread]
32.6 Mutual exclusion [thread.mutex]
32.6.5 Locks [thread.lock]
32.6.5.1 General [thread.lock.general]
A lock is an object that holds a reference to a lockable object and may unlock the lockable object during the lock's destruction (such as when leaving block scope).
An execution agent may use a lock to aid in managing ownership of a lockable object in an exception safe manner.
A lock is said to own a lockable object if it is currently managing the ownership of that lockable object for an execution agent.
A lock does not manage the lifetime of the lockable object it references.
[Note 1:
Locks are intended to ease the burden of unlocking the lockable object under both normal and exceptional circumstances.
— _end note_]
Some lock constructors take tag types which describe what should be done with the lockable object during the lock's construction.
namespace std { struct defer_lock_t { }; struct try_to_lock_t { }; struct adopt_lock_t { }; inline constexpr defer_lock_t defer_lock { };inline constexpr try_to_lock_t try_to_lock { };inline constexpr adopt_lock_t adopt_lock { };}