From Jason Turner

[thread.req.lockable]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp_t6a0bdi/{from.md → to.md} +94 -7
tmp/tmp_t6a0bdi/{from.md → to.md} RENAMED
@@ -19,17 +19,31 @@ The standard library templates `unique_lock` [[thread.lock.unique]],
19
  `shared_lock` [[thread.lock.shared]], `scoped_lock`
20
  [[thread.lock.scoped]], `lock_guard` [[thread.lock.guard]], `lock`,
21
  `try_lock` [[thread.lock.algorithm]], and `condition_variable_any`
22
  [[thread.condition.condvarany]] all operate on user-supplied lockable
23
  objects. The *Cpp17BasicLockable* requirements, the *Cpp17Lockable*
24
- requirements, and the *Cpp17TimedLockable* requirements list the
25
- requirements imposed by these library types in order to acquire or
26
- release ownership of a `lock` by a given execution agent.
 
 
27
 
28
  [*Note 3*: The nature of any lock ownership and any synchronization it
29
  entails are not part of these requirements. — *end note*]
30
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  #### *Cpp17BasicLockable* requirements <a id="thread.req.lockable.basic">[[thread.req.lockable.basic]]</a>
32
 
33
  A type `L` meets the *Cpp17BasicLockable* requirements if the following
34
  expressions are well-formed and have the specified semantics (`m`
35
  denotes a value of type `L`).
@@ -44,13 +58,15 @@ acquired for the current execution agent.
44
 
45
  ``` cpp
46
  m.unlock()
47
  ```
48
 
49
- *Preconditions:* The current execution agent holds a lock on `m`.
 
50
 
51
- *Effects:* Releases a lock on `m` held by the current execution agent.
 
52
 
53
  *Throws:* Nothing.
54
 
55
  #### *Cpp17Lockable* requirements <a id="thread.req.lockable.req">[[thread.req.lockable.req]]</a>
56
 
@@ -67,11 +83,11 @@ m.try_lock()
67
  without blocking. If an exception is thrown then a lock shall not have
68
  been acquired for the current execution agent.
69
 
70
  *Return type:* `bool`.
71
 
72
- *Returns:* `true` if the lock was acquired, `false` otherwise.
73
 
74
  #### *Cpp17TimedLockable* requirements <a id="thread.req.lockable.timed">[[thread.req.lockable.timed]]</a>
75
 
76
  A type `L` meets the *Cpp17TimedLockable* requirements if it meets the
77
  *Cpp17Lockable* requirements and the following expressions are
@@ -91,11 +107,11 @@ within the relative timeout [[thread.req.timing]] specified by
91
  execution agent. If an exception is thrown then a lock has not been
92
  acquired for the current execution agent.
93
 
94
  *Return type:* `bool`.
95
 
96
- *Returns:* `true` if the lock was acquired, `false` otherwise.
97
 
98
  ``` cpp
99
  m.try_lock_until(abs_time)
100
  ```
101
 
@@ -106,7 +122,78 @@ before the absolute timeout [[thread.req.timing]] specified by
106
  execution agent. If an exception is thrown then a lock has not been
107
  acquired for the current execution agent.
108
 
109
  *Return type:* `bool`.
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  *Returns:* `true` if the lock was acquired, `false` otherwise.
112
 
 
19
  `shared_lock` [[thread.lock.shared]], `scoped_lock`
20
  [[thread.lock.scoped]], `lock_guard` [[thread.lock.guard]], `lock`,
21
  `try_lock` [[thread.lock.algorithm]], and `condition_variable_any`
22
  [[thread.condition.condvarany]] all operate on user-supplied lockable
23
  objects. The *Cpp17BasicLockable* requirements, the *Cpp17Lockable*
24
+ requirements, the *Cpp17TimedLockable* requirements, the
25
+ *Cpp17SharedLockable* requirements, and the *Cpp17SharedTimedLockable*
26
+ requirements list the requirements imposed by these library types in
27
+ order to acquire or release ownership of a `lock` by a given execution
28
+ agent.
29
 
30
  [*Note 3*: The nature of any lock ownership and any synchronization it
31
  entails are not part of these requirements. — *end note*]
32
 
33
+ A lock on an object `m` is said to be
34
+
35
+ - a *non-shared lock* if it is acquired by a call to `lock`, `try_lock`,
36
+ `try_lock_for`, or `try_lock_until` on `m`, or
37
+ - a *shared lock* if it is acquired by a call to `lock_shared`,
38
+ `try_lock_shared`, `try_lock_shared_for`, or `try_lock_shared_until`
39
+ on `m`.
40
+
41
+ [*Note 4*: Only the method of lock acquisition is considered; the
42
+ nature of any lock ownership is not part of these
43
+ definitions. — *end note*]
44
+
45
  #### *Cpp17BasicLockable* requirements <a id="thread.req.lockable.basic">[[thread.req.lockable.basic]]</a>
46
 
47
  A type `L` meets the *Cpp17BasicLockable* requirements if the following
48
  expressions are well-formed and have the specified semantics (`m`
49
  denotes a value of type `L`).
 
58
 
59
  ``` cpp
60
  m.unlock()
61
  ```
62
 
63
+ *Preconditions:* The current execution agent holds a non-shared lock on
64
+ `m`.
65
 
66
+ *Effects:* Releases a non-shared lock on `m` held by the current
67
+ execution agent.
68
 
69
  *Throws:* Nothing.
70
 
71
  #### *Cpp17Lockable* requirements <a id="thread.req.lockable.req">[[thread.req.lockable.req]]</a>
72
 
 
83
  without blocking. If an exception is thrown then a lock shall not have
84
  been acquired for the current execution agent.
85
 
86
  *Return type:* `bool`.
87
 
88
+ *Returns:* `true` if the lock was acquired, otherwise `false`.
89
 
90
  #### *Cpp17TimedLockable* requirements <a id="thread.req.lockable.timed">[[thread.req.lockable.timed]]</a>
91
 
92
  A type `L` meets the *Cpp17TimedLockable* requirements if it meets the
93
  *Cpp17Lockable* requirements and the following expressions are
 
107
  execution agent. If an exception is thrown then a lock has not been
108
  acquired for the current execution agent.
109
 
110
  *Return type:* `bool`.
111
 
112
+ *Returns:* `true` if the lock was acquired, otherwise `false`.
113
 
114
  ``` cpp
115
  m.try_lock_until(abs_time)
116
  ```
117
 
 
122
  execution agent. If an exception is thrown then a lock has not been
123
  acquired for the current execution agent.
124
 
125
  *Return type:* `bool`.
126
 
127
+ *Returns:* `true` if the lock was acquired, otherwise `false`.
128
+
129
+ #### *Cpp17SharedLockable* requirements <a id="thread.req.lockable.shared">[[thread.req.lockable.shared]]</a>
130
+
131
+ A type `L` meets the *Cpp17SharedLockable* requirements if the following
132
+ expressions are well-formed, have the specified semantics, and the
133
+ expression `m.try_lock_shared()` has type `bool` (`m` denotes a value of
134
+ type `L`):
135
+
136
+ ``` cpp
137
+ m.lock_shared()
138
+ ```
139
+
140
+ *Effects:* Blocks until a lock can be acquired for the current execution
141
+ agent. If an exception is thrown then a lock shall not have been
142
+ acquired for the current execution agent.
143
+
144
+ ``` cpp
145
+ m.try_lock_shared()
146
+ ```
147
+
148
+ *Effects:* Attempts to acquire a lock for the current execution agent
149
+ without blocking. If an exception is thrown then a lock shall not have
150
+ been acquired for the current execution agent.
151
+
152
+ *Returns:* `true` if the lock was acquired, `false` otherwise.
153
+
154
+ ``` cpp
155
+ m.unlock_shared()
156
+ ```
157
+
158
+ *Preconditions:* The current execution agent holds a shared lock on `m`.
159
+
160
+ *Effects:* Releases a shared lock on `m` held by the current execution
161
+ agent.
162
+
163
+ *Throws:* Nothing.
164
+
165
+ #### *Cpp17SharedTimedLockable* requirements <a id="thread.req.lockable.shared.timed">[[thread.req.lockable.shared.timed]]</a>
166
+
167
+ A type `L` meets the *Cpp17SharedTimedLockable* requirements if it meets
168
+ the *Cpp17SharedLockable* requirements, and the following expressions
169
+ are well-formed, have type `bool`, and have the specified semantics (`m`
170
+ denotes a value of type `L`, `rel_time` denotes a value of a
171
+ specialization of `chrono::duration`, and `abs_time` denotes a value of
172
+ a specialization of `chrono::time_point`).
173
+
174
+ ``` cpp
175
+ m.try_lock_shared_for(rel_time)
176
+ ```
177
+
178
+ *Effects:* Attempts to acquire a lock for the current execution agent
179
+ within the relative timeout [[thread.req.timing]] specified by
180
+ `rel_time`. The function will not return within the timeout specified by
181
+ `rel_time` unless it has obtained a lock on `m` for the current
182
+ execution agent. If an exception is thrown then a lock has not been
183
+ acquired for the current execution agent.
184
+
185
+ *Returns:* `true` if the lock was acquired, `false` otherwise.
186
+
187
+ ``` cpp
188
+ m.try_lock_shared_until(abs_time)
189
+ ```
190
+
191
+ *Effects:* Attempts to acquire a lock for the current execution agent
192
+ before the absolute timeout [[thread.req.timing]] specified by
193
+ `abs_time`. The function will not return before the timeout specified by
194
+ `abs_time` unless it has obtained a lock on `m` for the current
195
+ execution agent. If an exception is thrown then a lock has not been
196
+ acquired for the current execution agent.
197
+
198
  *Returns:* `true` if the lock was acquired, `false` otherwise.
199