tmp/tmpk9fgx25c/{from.md → to.md}
RENAMED
|
@@ -55,18 +55,18 @@ required [[thread.req.exception]].
|
|
| 55 |
~condition_variable();
|
| 56 |
```
|
| 57 |
|
| 58 |
*Preconditions:* There is no thread blocked on `*this`.
|
| 59 |
|
| 60 |
-
[*Note 1*: That is, all threads have been notified; they
|
| 61 |
subsequently block on the lock specified in the wait. This relaxes the
|
| 62 |
usual rules, which would have required all wait calls to happen before
|
| 63 |
destruction. Only the notification to unblock the wait needs to happen
|
| 64 |
-
before destruction.
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
predicate. — *end note*]
|
| 69 |
|
| 70 |
``` cpp
|
| 71 |
void notify_one() noexcept;
|
| 72 |
```
|
|
@@ -98,21 +98,21 @@ locked by the calling thread, and either
|
|
| 98 |
- When unblocked, calls `lock.lock()` (possibly blocking on the lock),
|
| 99 |
then returns.
|
| 100 |
- The function will unblock when signaled by a call to `notify_one()` or
|
| 101 |
a call to `notify_all()`, or spuriously.
|
| 102 |
|
| 103 |
-
*Remarks:* If the function fails to meet the postcondition,
|
| 104 |
-
`terminate()` is called [[except.terminate]].
|
| 105 |
-
|
| 106 |
-
[*Note 2*: This can happen if the re-locking of the mutex throws an
|
| 107 |
-
exception. — *end note*]
|
| 108 |
-
|
| 109 |
*Ensures:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
|
| 110 |
the calling thread.
|
| 111 |
|
| 112 |
*Throws:* Nothing.
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
``` cpp
|
| 115 |
template<class Predicate>
|
| 116 |
void wait(unique_lock<mutex>& lock, Predicate pred);
|
| 117 |
```
|
| 118 |
|
|
@@ -129,21 +129,21 @@ locked by the calling thread, and either
|
|
| 129 |
``` cpp
|
| 130 |
while (!pred())
|
| 131 |
wait(lock);
|
| 132 |
```
|
| 133 |
|
| 134 |
-
*Remarks:* If the function fails to meet the postcondition,
|
| 135 |
-
`terminate()` is called [[except.terminate]].
|
| 136 |
-
|
| 137 |
-
[*Note 3*: This can happen if the re-locking of the mutex throws an
|
| 138 |
-
exception. — *end note*]
|
| 139 |
-
|
| 140 |
*Ensures:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
|
| 141 |
the calling thread.
|
| 142 |
|
| 143 |
*Throws:* Any exception thrown by `pred`.
|
| 144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
``` cpp
|
| 146 |
template<class Clock, class Duration>
|
| 147 |
cv_status wait_until(unique_lock<mutex>& lock,
|
| 148 |
const chrono::time_point<Clock, Duration>& abs_time);
|
| 149 |
```
|
|
@@ -165,25 +165,25 @@ locked by the calling thread, and either
|
|
| 165 |
call to `notify_all()`, expiration of the absolute
|
| 166 |
timeout [[thread.req.timing]] specified by `abs_time`, or spuriously.
|
| 167 |
- If the function exits via an exception, `lock.lock()` is called prior
|
| 168 |
to exiting the function.
|
| 169 |
|
| 170 |
-
*Remarks:* If the function fails to meet the postcondition,
|
| 171 |
-
`terminate()` is called [[except.terminate]].
|
| 172 |
-
|
| 173 |
-
[*Note 4*: This can happen if the re-locking of the mutex throws an
|
| 174 |
-
exception. — *end note*]
|
| 175 |
-
|
| 176 |
*Ensures:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
|
| 177 |
the calling thread.
|
| 178 |
|
| 179 |
*Returns:* `cv_status::timeout` if the absolute
|
| 180 |
timeout [[thread.req.timing]] specified by `abs_time` expired, otherwise
|
| 181 |
`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);
|
| 189 |
```
|
|
@@ -200,25 +200,25 @@ locked by the calling thread, and either
|
|
| 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, otherwise
|
| 207 |
`cv_status::no_timeout`.
|
| 208 |
|
| 209 |
-
*
|
| 210 |
-
|
|
|
|
|
|
|
| 211 |
|
| 212 |
[*Note 5*: This can happen if the re-locking of the mutex throws an
|
| 213 |
exception. — *end note*]
|
| 214 |
|
| 215 |
-
*Ensures:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
|
| 216 |
-
the calling thread.
|
| 217 |
-
|
| 218 |
-
*Throws:* Timeout-related exceptions [[thread.req.timing]].
|
| 219 |
-
|
| 220 |
``` cpp
|
| 221 |
template<class Clock, class Duration, class Predicate>
|
| 222 |
bool wait_until(unique_lock<mutex>& lock,
|
| 223 |
const chrono::time_point<Clock, Duration>& abs_time,
|
| 224 |
Predicate pred);
|
|
@@ -239,26 +239,26 @@ while (!pred())
|
|
| 239 |
if (wait_until(lock, abs_time) == cv_status::timeout)
|
| 240 |
return pred();
|
| 241 |
return true;
|
| 242 |
```
|
| 243 |
|
| 244 |
-
*Remarks:* If the function fails to meet the postcondition,
|
| 245 |
-
`terminate()` is called [[except.terminate]].
|
| 246 |
-
|
| 247 |
-
[*Note 6*: This can happen if the re-locking of the mutex throws an
|
| 248 |
-
exception. — *end note*]
|
| 249 |
-
|
| 250 |
*Ensures:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
|
| 251 |
the calling thread.
|
| 252 |
|
| 253 |
-
[*Note
|
| 254 |
to `true` regardless of whether the timeout was
|
| 255 |
triggered. — *end note*]
|
| 256 |
|
| 257 |
*Throws:* Timeout-related exceptions [[thread.req.timing]] or any
|
| 258 |
exception thrown by `pred`.
|
| 259 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
``` cpp
|
| 261 |
template<class Rep, class Period, class Predicate>
|
| 262 |
bool wait_for(unique_lock<mutex>& lock,
|
| 263 |
const chrono::duration<Rep, Period>& rel_time,
|
| 264 |
Predicate pred);
|
|
@@ -279,21 +279,21 @@ return wait_until(lock, chrono::steady_clock::now() + rel_time, std::move(pred))
|
|
| 279 |
```
|
| 280 |
|
| 281 |
[*Note 8*: There is no blocking if `pred()` is initially `true`, even
|
| 282 |
if the timeout has already expired. — *end note*]
|
| 283 |
|
| 284 |
-
*Remarks:* If the function fails to meet the postcondition,
|
| 285 |
-
`terminate()` is called [[except.terminate]].
|
| 286 |
-
|
| 287 |
-
[*Note 9*: This can happen if the re-locking of the mutex throws an
|
| 288 |
-
exception. — *end note*]
|
| 289 |
-
|
| 290 |
*Ensures:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
|
| 291 |
the calling thread.
|
| 292 |
|
| 293 |
-
[*Note
|
| 294 |
-
|
| 295 |
triggered. — *end note*]
|
| 296 |
|
| 297 |
*Throws:* Timeout-related exceptions [[thread.req.timing]] or any
|
| 298 |
exception thrown by `pred`.
|
| 299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
~condition_variable();
|
| 56 |
```
|
| 57 |
|
| 58 |
*Preconditions:* There is no thread blocked on `*this`.
|
| 59 |
|
| 60 |
+
[*Note 1*: That is, all threads have been notified; they can
|
| 61 |
subsequently block on the lock specified in the wait. This relaxes the
|
| 62 |
usual rules, which would have required all wait calls to happen before
|
| 63 |
destruction. Only the notification to unblock the wait needs to happen
|
| 64 |
+
before destruction. Undefined behavior ensues if a thread waits on
|
| 65 |
+
`*this` once the destructor has been started, especially when the
|
| 66 |
+
waiting threads are calling the wait functions in a loop or using the
|
| 67 |
+
overloads of `wait`, `wait_for`, or `wait_until` that take a
|
| 68 |
predicate. — *end note*]
|
| 69 |
|
| 70 |
``` cpp
|
| 71 |
void notify_one() noexcept;
|
| 72 |
```
|
|
|
|
| 98 |
- When unblocked, calls `lock.lock()` (possibly blocking on the lock),
|
| 99 |
then returns.
|
| 100 |
- The function will unblock when signaled by a call to `notify_one()` or
|
| 101 |
a call to `notify_all()`, or spuriously.
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
*Ensures:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
|
| 104 |
the calling thread.
|
| 105 |
|
| 106 |
*Throws:* Nothing.
|
| 107 |
|
| 108 |
+
*Remarks:* If the function fails to meet the postcondition,
|
| 109 |
+
`terminate()` is invoked [[except.terminate]].
|
| 110 |
+
|
| 111 |
+
[*Note 2*: This can happen if the re-locking of the mutex throws an
|
| 112 |
+
exception. — *end note*]
|
| 113 |
+
|
| 114 |
``` cpp
|
| 115 |
template<class Predicate>
|
| 116 |
void wait(unique_lock<mutex>& lock, Predicate pred);
|
| 117 |
```
|
| 118 |
|
|
|
|
| 129 |
``` cpp
|
| 130 |
while (!pred())
|
| 131 |
wait(lock);
|
| 132 |
```
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
*Ensures:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
|
| 135 |
the calling thread.
|
| 136 |
|
| 137 |
*Throws:* Any exception thrown by `pred`.
|
| 138 |
|
| 139 |
+
*Remarks:* If the function fails to meet the postcondition,
|
| 140 |
+
`terminate()` is invoked [[except.terminate]].
|
| 141 |
+
|
| 142 |
+
[*Note 3*: This can happen if the re-locking of the mutex throws an
|
| 143 |
+
exception. — *end note*]
|
| 144 |
+
|
| 145 |
``` cpp
|
| 146 |
template<class Clock, class Duration>
|
| 147 |
cv_status wait_until(unique_lock<mutex>& lock,
|
| 148 |
const chrono::time_point<Clock, Duration>& abs_time);
|
| 149 |
```
|
|
|
|
| 165 |
call to `notify_all()`, expiration of the absolute
|
| 166 |
timeout [[thread.req.timing]] specified by `abs_time`, or spuriously.
|
| 167 |
- If the function exits via an exception, `lock.lock()` is called prior
|
| 168 |
to exiting the function.
|
| 169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
*Ensures:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
|
| 171 |
the calling thread.
|
| 172 |
|
| 173 |
*Returns:* `cv_status::timeout` if the absolute
|
| 174 |
timeout [[thread.req.timing]] specified by `abs_time` expired, otherwise
|
| 175 |
`cv_status::no_timeout`.
|
| 176 |
|
| 177 |
*Throws:* Timeout-related exceptions [[thread.req.timing]].
|
| 178 |
|
| 179 |
+
*Remarks:* If the function fails to meet the postcondition,
|
| 180 |
+
`terminate()` is invoked [[except.terminate]].
|
| 181 |
+
|
| 182 |
+
[*Note 4*: This can happen if the re-locking of the mutex throws an
|
| 183 |
+
exception. — *end note*]
|
| 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);
|
| 189 |
```
|
|
|
|
| 200 |
|
| 201 |
``` cpp
|
| 202 |
return wait_until(lock, chrono::steady_clock::now() + rel_time);
|
| 203 |
```
|
| 204 |
|
| 205 |
+
*Ensures:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
|
| 206 |
+
the calling thread.
|
| 207 |
+
|
| 208 |
*Returns:* `cv_status::timeout` if the relative
|
| 209 |
timeout [[thread.req.timing]] specified by `rel_time` expired, otherwise
|
| 210 |
`cv_status::no_timeout`.
|
| 211 |
|
| 212 |
+
*Throws:* Timeout-related exceptions [[thread.req.timing]].
|
| 213 |
+
|
| 214 |
+
*Remarks:* If the function fails to meet the postcondition, `terminate`
|
| 215 |
+
is invoked [[except.terminate]].
|
| 216 |
|
| 217 |
[*Note 5*: This can happen if the re-locking of the mutex throws an
|
| 218 |
exception. — *end note*]
|
| 219 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
``` cpp
|
| 221 |
template<class Clock, class Duration, class Predicate>
|
| 222 |
bool wait_until(unique_lock<mutex>& lock,
|
| 223 |
const chrono::time_point<Clock, Duration>& abs_time,
|
| 224 |
Predicate pred);
|
|
|
|
| 239 |
if (wait_until(lock, abs_time) == cv_status::timeout)
|
| 240 |
return pred();
|
| 241 |
return true;
|
| 242 |
```
|
| 243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
*Ensures:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
|
| 245 |
the calling thread.
|
| 246 |
|
| 247 |
+
[*Note 6*: The returned value indicates whether the predicate evaluated
|
| 248 |
to `true` regardless of whether the timeout was
|
| 249 |
triggered. — *end note*]
|
| 250 |
|
| 251 |
*Throws:* Timeout-related exceptions [[thread.req.timing]] or any
|
| 252 |
exception thrown by `pred`.
|
| 253 |
|
| 254 |
+
*Remarks:* If the function fails to meet the postcondition,
|
| 255 |
+
`terminate()` is invoked [[except.terminate]].
|
| 256 |
+
|
| 257 |
+
[*Note 7*: This can happen if the re-locking of the mutex throws an
|
| 258 |
+
exception. — *end note*]
|
| 259 |
+
|
| 260 |
``` cpp
|
| 261 |
template<class Rep, class Period, class Predicate>
|
| 262 |
bool wait_for(unique_lock<mutex>& lock,
|
| 263 |
const chrono::duration<Rep, Period>& rel_time,
|
| 264 |
Predicate pred);
|
|
|
|
| 279 |
```
|
| 280 |
|
| 281 |
[*Note 8*: There is no blocking if `pred()` is initially `true`, even
|
| 282 |
if the timeout has already expired. — *end note*]
|
| 283 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
*Ensures:* `lock.owns_lock()` is `true` and `lock.mutex()` is locked by
|
| 285 |
the calling thread.
|
| 286 |
|
| 287 |
+
[*Note 9*: The returned value indicates whether the predicate evaluates
|
| 288 |
+
to `true` regardless of whether the timeout was
|
| 289 |
triggered. — *end note*]
|
| 290 |
|
| 291 |
*Throws:* Timeout-related exceptions [[thread.req.timing]] or any
|
| 292 |
exception thrown by `pred`.
|
| 293 |
|
| 294 |
+
*Remarks:* If the function fails to meet the postcondition,
|
| 295 |
+
`terminate()` is invoked [[except.terminate]].
|
| 296 |
+
|
| 297 |
+
[*Note 10*: This can happen if the re-locking of the mutex throws an
|
| 298 |
+
exception. — *end note*]
|
| 299 |
+
|