From Jason Turner

[thread.condition.condvar]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpnggb_2ml/{from.md → to.md} +43 -52
tmp/tmpnggb_2ml/{from.md → to.md} RENAMED
@@ -91,32 +91,29 @@ void wait(unique_lock<mutex>& lock);
91
  `lock.owns_lock()` is `true` and `lock.mutex()` is locked by the calling
92
  thread, and either
93
 
94
  - no other thread is waiting on this `condition_variable` object or
95
  - `lock.mutex()` returns the same value for each of the `lock` arguments
96
- supplied by all concurrently waiting (via `wait` or `timed_wait`)
97
- threads.
98
 
99
  *Effects:*
100
 
101
  - Atomically calls `lock.unlock()` and blocks on `*this`.
102
  - When unblocked, calls `lock.lock()` (possibly blocking on the lock),
103
  then returns.
104
  - The function will unblock when signaled by a call to `notify_one()` or
105
  a call to `notify_all()`, or spuriously.
106
- - If the function exits via an exception, `lock.lock()` shall be called
107
- prior to exiting the function scope.
 
 
108
 
109
  `lock.owns_lock()` is `true` and `lock.mutex()` is locked by the calling
110
  thread.
111
 
112
- *Throws:* `system_error` when an exception is
113
- required ([[thread.req.exception]]).
114
-
115
- *Error conditions:*
116
-
117
- - equivalent error condition from `lock.lock()` or `lock.unlock()`.
118
 
119
  ``` cpp
120
  template <class Predicate>
121
  void wait(unique_lock<mutex>& lock, Predicate pred);
122
  ```
@@ -124,29 +121,29 @@ template <class Predicate>
124
  *Requires:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
125
  the calling thread, and either
126
 
127
  - no other thread is waiting on this `condition_variable` object or
128
  - `lock.mutex()` returns the same value for each of the `lock` arguments
129
- supplied by all concurrently waiting (via `wait` or `timed_wait`)
130
- threads.
131
 
132
- *Effects:*
133
 
134
  ``` cpp
135
  while (!pred())
136
  wait(lock);
137
  ```
138
 
 
 
 
 
139
  `lock.owns_lock()` is `true` and `lock.mutex()` is locked by the calling
140
  thread.
141
 
142
- *Throws:* `std::system_error` when an exception is
143
- required ([[thread.req.exception]]).
144
-
145
- *Error conditions:*
146
-
147
- - equivalent error condition from `lock.lock()` or `lock.unlock()`.
148
 
149
  ``` cpp
150
  template <class Clock, class Duration>
151
  cv_status wait_until(unique_lock<mutex>& lock,
152
  const chrono::time_point<Clock, Duration>& abs_time);
@@ -168,25 +165,24 @@ thread, and either
168
  - The function will unblock when signaled by a call to `notify_one()`, a
169
  call to `notify_all()`, expiration of the absolute
170
  timeout ([[thread.req.timing]]) specified by `abs_time`, or
171
  spuriously.
172
  - If the function exits via an exception, `lock.lock()` shall be called
173
- prior to exiting the function scope.
 
 
 
 
174
 
175
  `lock.owns_lock()` is `true` and `lock.mutex()` is locked by the calling
176
  thread.
177
 
178
  *Returns:* `cv_status::timeout` if the absolute
179
  timeout ([[thread.req.timing]]) specified by `abs_time` expired,
180
  otherwise `cv_status::no_timeout`.
181
 
182
- *Throws:* `system_error` when an exception is
183
- required ([[thread.req.exception]]).
184
-
185
- *Error conditions:*
186
-
187
- - equivalent error condition from `lock.lock()` or `lock.unlock()`.
188
 
189
  ``` cpp
190
  template <class Rep, class Period>
191
  cv_status wait_for(unique_lock<mutex>& lock,
192
  const chrono::duration<Rep, Period>& rel_time);
@@ -198,29 +194,28 @@ thread, and either
198
  - no other thread is waiting on this `condition_variable` object or
199
  - `lock.mutex()` returns the same value for each of the `lock` arguments
200
  supplied by all concurrently waiting (via `wait`, `wait_for`, or
201
  `wait_until`) threads.
202
 
203
- *Effects:* as if
204
 
205
  ``` cpp
206
  return wait_until(lock, chrono::steady_clock::now() + rel_time);
207
  ```
208
 
209
  *Returns:* `cv_status::timeout` if the relative
210
  timeout ([[thread.req.timing]]) specified by `rel_time` expired,
211
  otherwise `cv_status::no_timeout`.
212
 
 
 
 
 
213
  `lock.owns_lock()` is `true` and `lock.mutex()` is locked by the calling
214
  thread.
215
 
216
- *Throws:* `system_error` when an exception is
217
- required ([[thread.req.exception]]).
218
-
219
- *Error conditions:*
220
-
221
- - equivalent error condition from `lock.lock()` or `lock.unlock()`.
222
 
223
  ``` cpp
224
  template <class Clock, class Duration, class Predicate>
225
  bool wait_until(unique_lock<mutex>& lock,
226
  const chrono::time_point<Clock, Duration>& abs_time,
@@ -230,36 +225,34 @@ template <class Clock, class Duration, class Predicate>
230
  *Requires:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
231
  the calling thread, and either
232
 
233
  - no other thread is waiting on this `condition_variable` object or
234
  - `lock.mutex()` returns the same value for each of the `lock` arguments
235
- supplied by all concurrently waiting (via `wait` or `timed_wait`)
236
- threads.
237
 
238
- *Effects:*
239
 
240
  ``` cpp
241
  while (!pred())
242
  if (wait_until(lock, abs_time) == cv_status::timeout)
243
  return pred();
244
  return true;
245
  ```
246
 
247
- *Returns:* `pred()`
 
 
248
 
249
  `lock.owns_lock()` is `true` and `lock.mutex()` is locked by the calling
250
  thread.
251
 
252
  The returned value indicates whether the predicate evaluated to `true`
253
  regardless of whether the timeout was triggered.
254
 
255
- *Throws:* `std::system_error` when an exception is
256
- required ([[thread.req.exception]]).
257
-
258
- *Error conditions:*
259
-
260
- - equivalent error condition from `lock.lock()` or `lock.unlock()`.
261
 
262
  ``` cpp
263
  template <class Rep, class Period, class Predicate>
264
  bool wait_for(unique_lock<mutex>& lock,
265
  const chrono::duration<Rep, Period>& rel_time,
@@ -272,29 +265,27 @@ thread, and either
272
  - no other thread is waiting on this `condition_variable` object or
273
  - `lock.mutex()` returns the same value for each of the `lock` arguments
274
  supplied by all concurrently waiting (via `wait`, `wait_for`, or
275
  `wait_until`) threads.
276
 
277
- *Effects:* as if
278
 
279
  ``` cpp
280
  return wait_until(lock, chrono::steady_clock::now() + rel_time, std::move(pred));
281
  ```
282
 
283
  There is no blocking if `pred()` is initially `true`, even if the
284
  timeout has already expired.
285
 
 
 
 
 
286
  `lock.owns_lock()` is `true` and `lock.mutex()` is locked by the calling
287
  thread.
288
 
289
- *Returns:* `pred()`
290
-
291
  The returned value indicates whether the predicate evaluates to `true`
292
  regardless of whether the timeout was triggered.
293
 
294
- *Throws:* `system_error` when an exception is
295
- required ([[thread.req.exception]]).
296
-
297
- *Error conditions:*
298
-
299
- - equivalent error condition from `lock.lock()` or `lock.unlock()`.
300
 
 
91
  `lock.owns_lock()` is `true` and `lock.mutex()` is locked by the calling
92
  thread, and either
93
 
94
  - no other thread is waiting on this `condition_variable` object or
95
  - `lock.mutex()` returns the same value for each of the `lock` arguments
96
+ supplied by all concurrently waiting (via `wait`, `wait_for`, or
97
+ `wait_until`) threads.
98
 
99
  *Effects:*
100
 
101
  - Atomically calls `lock.unlock()` and blocks on `*this`.
102
  - When unblocked, calls `lock.lock()` (possibly blocking on the lock),
103
  then returns.
104
  - The function will unblock when signaled by a call to `notify_one()` or
105
  a call to `notify_all()`, or spuriously.
106
+
107
+ *Remarks:* If the function fails to meet the postcondition,
108
+ `std::terminate()` shall be called ([[except.terminate]]). This can
109
+ happen if the re-locking of the mutex throws an exception.
110
 
111
  `lock.owns_lock()` is `true` and `lock.mutex()` is locked by the calling
112
  thread.
113
 
114
+ *Throws:* Nothing.
 
 
 
 
 
115
 
116
  ``` cpp
117
  template <class Predicate>
118
  void wait(unique_lock<mutex>& lock, Predicate pred);
119
  ```
 
121
  *Requires:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
122
  the calling thread, and either
123
 
124
  - no other thread is waiting on this `condition_variable` object or
125
  - `lock.mutex()` returns the same value for each of the `lock` arguments
126
+ supplied by all concurrently waiting (via `wait`, `wait_for`, or
127
+ `wait_until`) threads.
128
 
129
+ *Effects:* Equivalent to:
130
 
131
  ``` cpp
132
  while (!pred())
133
  wait(lock);
134
  ```
135
 
136
+ *Remarks:* If the function fails to meet the postcondition,
137
+ `std::terminate()` shall be called ([[except.terminate]]). This can
138
+ happen if the re-locking of the mutex throws an exception.
139
+
140
  `lock.owns_lock()` is `true` and `lock.mutex()` is locked by the calling
141
  thread.
142
 
143
+ *Throws:* Timeout-related exceptions ([[thread.req.timing]]) or any
144
+ exception thrown by `pred`.
 
 
 
 
145
 
146
  ``` cpp
147
  template <class Clock, class Duration>
148
  cv_status wait_until(unique_lock<mutex>& lock,
149
  const chrono::time_point<Clock, Duration>& abs_time);
 
165
  - The function will unblock when signaled by a call to `notify_one()`, a
166
  call to `notify_all()`, expiration of the absolute
167
  timeout ([[thread.req.timing]]) specified by `abs_time`, or
168
  spuriously.
169
  - If the function exits via an exception, `lock.lock()` shall be called
170
+ prior to exiting the function.
171
+
172
+ *Remarks:* If the function fails to meet the postcondition,
173
+ `std::terminate()` shall be called ([[except.terminate]]). This can
174
+ happen if the re-locking of the mutex throws an exception.
175
 
176
  `lock.owns_lock()` is `true` and `lock.mutex()` is locked by the calling
177
  thread.
178
 
179
  *Returns:* `cv_status::timeout` if the absolute
180
  timeout ([[thread.req.timing]]) specified by `abs_time` expired,
181
  otherwise `cv_status::no_timeout`.
182
 
183
+ *Throws:* Timeout-related exceptions ([[thread.req.timing]]).
 
 
 
 
 
184
 
185
  ``` cpp
186
  template <class Rep, class Period>
187
  cv_status wait_for(unique_lock<mutex>& lock,
188
  const chrono::duration<Rep, Period>& rel_time);
 
194
  - no other thread is waiting on this `condition_variable` object or
195
  - `lock.mutex()` returns the same value for each of the `lock` arguments
196
  supplied by all concurrently waiting (via `wait`, `wait_for`, or
197
  `wait_until`) threads.
198
 
199
+ *Effects:* Equivalent to:
200
 
201
  ``` cpp
202
  return wait_until(lock, chrono::steady_clock::now() + rel_time);
203
  ```
204
 
205
  *Returns:* `cv_status::timeout` if the relative
206
  timeout ([[thread.req.timing]]) specified by `rel_time` expired,
207
  otherwise `cv_status::no_timeout`.
208
 
209
+ *Remarks:* If the function fails to meet the postcondition,
210
+ `std::terminate()` shall be called ([[except.terminate]]). This can
211
+ happen if the re-locking of the mutex throws an exception.
212
+
213
  `lock.owns_lock()` is `true` and `lock.mutex()` is locked by the calling
214
  thread.
215
 
216
+ *Throws:* Timeout-related exceptions ([[thread.req.timing]]).
 
 
 
 
 
217
 
218
  ``` cpp
219
  template <class Clock, class Duration, class Predicate>
220
  bool wait_until(unique_lock<mutex>& lock,
221
  const chrono::time_point<Clock, Duration>& abs_time,
 
225
  *Requires:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
226
  the calling thread, and either
227
 
228
  - no other thread is waiting on this `condition_variable` object or
229
  - `lock.mutex()` returns the same value for each of the `lock` arguments
230
+ supplied by all concurrently waiting (via `wait`, `wait_for`, or
231
+ `wait_until`) threads.
232
 
233
+ *Effects:* Equivalent to:
234
 
235
  ``` cpp
236
  while (!pred())
237
  if (wait_until(lock, abs_time) == cv_status::timeout)
238
  return pred();
239
  return true;
240
  ```
241
 
242
+ *Remarks:* If the function fails to meet the postcondition,
243
+ `std::terminate()` shall be called ([[except.terminate]]). This can
244
+ happen if the re-locking of the mutex throws an exception.
245
 
246
  `lock.owns_lock()` is `true` and `lock.mutex()` is locked by the calling
247
  thread.
248
 
249
  The returned value indicates whether the predicate evaluated to `true`
250
  regardless of whether the timeout was triggered.
251
 
252
+ *Throws:* Timeout-related exceptions ([[thread.req.timing]]) or any
253
+ exception thrown by `pred`.
 
 
 
 
254
 
255
  ``` cpp
256
  template <class Rep, class Period, class Predicate>
257
  bool wait_for(unique_lock<mutex>& lock,
258
  const chrono::duration<Rep, Period>& rel_time,
 
265
  - no other thread is waiting on this `condition_variable` object or
266
  - `lock.mutex()` returns the same value for each of the `lock` arguments
267
  supplied by all concurrently waiting (via `wait`, `wait_for`, or
268
  `wait_until`) threads.
269
 
270
+ *Effects:* Equivalent to:
271
 
272
  ``` cpp
273
  return wait_until(lock, chrono::steady_clock::now() + rel_time, std::move(pred));
274
  ```
275
 
276
  There is no blocking if `pred()` is initially `true`, even if the
277
  timeout has already expired.
278
 
279
+ *Remarks:* If the function fails to meet the postcondition,
280
+ `std::terminate()` shall be called ([[except.terminate]]). This can
281
+ happen if the re-locking of the mutex throws an exception.
282
+
283
  `lock.owns_lock()` is `true` and `lock.mutex()` is locked by the calling
284
  thread.
285
 
 
 
286
  The returned value indicates whether the predicate evaluates to `true`
287
  regardless of whether the timeout was triggered.
288
 
289
+ *Throws:* Timeout-related exceptions ([[thread.req.timing]]) or any
290
+ exception thrown by `pred`.
 
 
 
 
291