tmp/tmpm5dzhhao/{from.md → to.md}
RENAMED
|
@@ -25,18 +25,18 @@ return pred();
|
|
| 25 |
[*Note 1*: The returned value indicates whether the predicate evaluated
|
| 26 |
to `true` regardless of whether there was a stop request. — *end note*]
|
| 27 |
|
| 28 |
*Ensures:* `lock` is locked by the calling thread.
|
| 29 |
|
| 30 |
-
*Remarks:* If the function fails to meet the postcondition, `terminate`
|
| 31 |
-
is called [[except.terminate]].
|
| 32 |
-
|
| 33 |
-
[*Note 2*: This can happen if the re-locking of the mutex throws an
|
| 34 |
-
exception. — *end note*]
|
| 35 |
-
|
| 36 |
*Throws:* Any exception thrown by `pred`.
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
``` cpp
|
| 39 |
template<class Lock, class Clock, class Duration, class Predicate>
|
| 40 |
bool wait_until(Lock& lock, stop_token stoken,
|
| 41 |
const chrono::time_point<Clock, Duration>& abs_time, Predicate pred);
|
| 42 |
```
|
|
@@ -47,11 +47,11 @@ equivalent to:
|
|
| 47 |
|
| 48 |
``` cpp
|
| 49 |
while (!stoken.stop_requested()) {
|
| 50 |
if (pred())
|
| 51 |
return true;
|
| 52 |
-
if (
|
| 53 |
return pred();
|
| 54 |
}
|
| 55 |
return pred();
|
| 56 |
```
|
| 57 |
|
|
@@ -63,19 +63,19 @@ expired. — *end note*]
|
|
| 63 |
to `true` regardless of whether the timeout was triggered or a stop
|
| 64 |
request was made. — *end note*]
|
| 65 |
|
| 66 |
*Ensures:* `lock` is locked by the calling thread.
|
| 67 |
|
| 68 |
-
*Remarks:* If the function fails to meet the postcondition, `terminate`
|
| 69 |
-
is called [[except.terminate]].
|
| 70 |
-
|
| 71 |
-
[*Note 5*: This can happen if the re-locking of the mutex throws an
|
| 72 |
-
exception. — *end note*]
|
| 73 |
-
|
| 74 |
*Throws:* Timeout-related exceptions [[thread.req.timing]], or any
|
| 75 |
exception thrown by `pred`.
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
``` cpp
|
| 78 |
template<class Lock, class Rep, class Period, class Predicate>
|
| 79 |
bool wait_for(Lock& lock, stop_token stoken,
|
| 80 |
const chrono::duration<Rep, Period>& rel_time, Predicate pred);
|
| 81 |
```
|
|
|
|
| 25 |
[*Note 1*: The returned value indicates whether the predicate evaluated
|
| 26 |
to `true` regardless of whether there was a stop request. — *end note*]
|
| 27 |
|
| 28 |
*Ensures:* `lock` is locked by the calling thread.
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
*Throws:* Any exception thrown by `pred`.
|
| 31 |
|
| 32 |
+
*Remarks:* If the function fails to meet the postcondition, `terminate`
|
| 33 |
+
is called [[except.terminate]].
|
| 34 |
+
|
| 35 |
+
[*Note 2*: This can happen if the re-locking of the mutex throws an
|
| 36 |
+
exception. — *end note*]
|
| 37 |
+
|
| 38 |
``` cpp
|
| 39 |
template<class Lock, class Clock, class Duration, class Predicate>
|
| 40 |
bool wait_until(Lock& lock, stop_token stoken,
|
| 41 |
const chrono::time_point<Clock, Duration>& abs_time, Predicate pred);
|
| 42 |
```
|
|
|
|
| 47 |
|
| 48 |
``` cpp
|
| 49 |
while (!stoken.stop_requested()) {
|
| 50 |
if (pred())
|
| 51 |
return true;
|
| 52 |
+
if (wait_until(lock, abs_time) == cv_status::timeout)
|
| 53 |
return pred();
|
| 54 |
}
|
| 55 |
return pred();
|
| 56 |
```
|
| 57 |
|
|
|
|
| 63 |
to `true` regardless of whether the timeout was triggered or a stop
|
| 64 |
request was made. — *end note*]
|
| 65 |
|
| 66 |
*Ensures:* `lock` is locked by the calling thread.
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
*Throws:* Timeout-related exceptions [[thread.req.timing]], or any
|
| 69 |
exception thrown by `pred`.
|
| 70 |
|
| 71 |
+
*Remarks:* If the function fails to meet the postcondition, `terminate`
|
| 72 |
+
is called [[except.terminate]].
|
| 73 |
+
|
| 74 |
+
[*Note 5*: This can happen if the re-locking of the mutex throws an
|
| 75 |
+
exception. — *end note*]
|
| 76 |
+
|
| 77 |
``` cpp
|
| 78 |
template<class Lock, class Rep, class Period, class Predicate>
|
| 79 |
bool wait_for(Lock& lock, stop_token stoken,
|
| 80 |
const chrono::duration<Rep, Period>& rel_time, Predicate pred);
|
| 81 |
```
|