This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
[thread.lock.general]
# 32 Concurrency support library [[thread]](./#thread)
## 32.6 Mutual exclusion [[thread.mutex]](thread.mutex#thread.lock.general)
### 32.6.5 Locks [[thread.lock]](thread.lock#general)
#### 32.6.5.1 General [thread.lock.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L8144)
A [*lock*](#def: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)[.](#1.sentence-1)
An execution
agent may use a lock to aid in managing ownership of a lockable object in an exception safe
manner[.](#1.sentence-2)
A lock is said to [*own*](#def:own) a lockable object if it is currently managing the
ownership of that lockable object for an execution agent[.](#1.sentence-3)
A lock does not manage the lifetime
of the lockable object it references[.](#1.sentence-4)
[*Note [1](#note-1)*:
Locks are intended to ease the burden of
unlocking the lockable object under both normal and exceptional circumstances[.](#1.sentence-5)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/threads.tex#L8156)
Some lock constructors take tag types which describe what should be done with the lockable
object during the lock's construction[.](#2.sentence-1)
[🔗](#lib:defer_lock_t)
namespace std {struct defer_lock_t { }; // do not acquire ownership of the mutexstruct try_to_lock_t { }; // try to acquire ownership of the mutex// without blockingstruct adopt_lock_t { }; // assume the calling thread has already// obtained mutex ownership and manage itinline constexpr defer_lock_t defer_lock { }; inline constexpr try_to_lock_t try_to_lock { }; inline constexpr adopt_lock_t adopt_lock { };}