From Jason Turner

[thread.sharedmutex.requirements.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmptp6gkvwo/{from.md → to.md} +87 -0
tmp/tmptp6gkvwo/{from.md → to.md} RENAMED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##### General <a id="thread.sharedmutex.requirements.general">[[thread.sharedmutex.requirements.general]]</a>
2
+
3
+ The standard library types `shared_mutex` and `shared_timed_mutex` are
4
+ *shared mutex types*. Shared mutex types meet the requirements of mutex
5
+ types [[thread.mutex.requirements.mutex]] and additionally meet the
6
+ requirements set out below. In this description, `m` denotes an object
7
+ of a shared mutex type.
8
+
9
+ [*Note 1*: The shared mutex types meet the *Cpp17SharedLockable*
10
+ requirements [[thread.req.lockable.shared]]. — *end note*]
11
+
12
+ In addition to the exclusive lock ownership mode specified in 
13
+ [[thread.mutex.requirements.mutex]], shared mutex types provide a
14
+ *shared lock* ownership mode. Multiple execution agents can
15
+ simultaneously hold a shared lock ownership of a shared mutex type. But
16
+ no execution agent holds a shared lock while another execution agent
17
+ holds an exclusive lock on the same shared mutex type, and vice-versa.
18
+ The maximum number of execution agents which can share a shared lock on
19
+ a single shared mutex type is unspecified, but is at least 10000. If
20
+ more than the maximum number of execution agents attempt to obtain a
21
+ shared lock, the excess execution agents block until the number of
22
+ shared locks are reduced below the maximum amount by other execution
23
+ agents releasing their shared lock.
24
+
25
+ The expression `m.lock_shared()` is well-formed and has the following
26
+ semantics:
27
+
28
+ *Preconditions:* The calling thread has no ownership of the mutex.
29
+
30
+ *Effects:* Blocks the calling thread until shared ownership of the mutex
31
+ can be obtained for the calling thread. If an exception is thrown then a
32
+ shared lock has not been acquired for the current thread.
33
+
34
+ *Synchronization:* Prior `unlock()` operations on the same object
35
+ synchronize with [[intro.multithread]] this operation.
36
+
37
+ *Ensures:* The calling thread has a shared lock on the mutex.
38
+
39
+ *Return type:* `void`.
40
+
41
+ *Throws:* `system_error` when an exception is
42
+ required [[thread.req.exception]].
43
+
44
+ *Error conditions:*
45
+
46
+ - `operation_not_permitted` — if the thread does not have the privilege
47
+ to perform the operation.
48
+ - `resource_deadlock_would_occur` — if the implementation detects that a
49
+ deadlock would occur.
50
+
51
+ The expression `m.unlock_shared()` is well-formed and has the following
52
+ semantics:
53
+
54
+ *Preconditions:* The calling thread holds a shared lock on the mutex.
55
+
56
+ *Effects:* Releases a shared lock on the mutex held by the calling
57
+ thread.
58
+
59
+ *Return type:* `void`.
60
+
61
+ *Synchronization:* This operation synchronizes
62
+ with [[intro.multithread]] subsequent `lock()` operations that obtain
63
+ ownership on the same object.
64
+
65
+ *Throws:* Nothing.
66
+
67
+ The expression `m.try_lock_shared()` is well-formed and has the
68
+ following semantics:
69
+
70
+ *Preconditions:* The calling thread has no ownership of the mutex.
71
+
72
+ *Effects:* Attempts to obtain shared ownership of the mutex for the
73
+ calling thread without blocking. If shared ownership is not obtained,
74
+ there is no effect and `try_lock_shared()` immediately returns. An
75
+ implementation may fail to obtain the lock even if it is not held by any
76
+ other thread.
77
+
78
+ *Synchronization:* If `try_lock_shared()` returns `true`, prior
79
+ `unlock()` operations on the same object synchronize
80
+ with [[intro.multithread]] this operation.
81
+
82
+ *Return type:* `bool`.
83
+
84
+ *Returns:* `true` if the shared lock was acquired, otherwise `false`.
85
+
86
+ *Throws:* Nothing.
87
+