tmp/tmpudxg3khj/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Noninterruptible waits <a id="thread.condvarany.wait">[[thread.condvarany.wait]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
template<class Lock>
|
| 5 |
+
void wait(Lock& lock);
|
| 6 |
+
```
|
| 7 |
+
|
| 8 |
+
*Effects:*
|
| 9 |
+
|
| 10 |
+
- Atomically calls `lock.unlock()` and blocks on `*this`.
|
| 11 |
+
- When unblocked, calls `lock.lock()` (possibly blocking on the lock)
|
| 12 |
+
and returns.
|
| 13 |
+
- The function will unblock when signaled by a call to `notify_one()`, a
|
| 14 |
+
call to `notify_all()`, or spuriously.
|
| 15 |
+
|
| 16 |
+
*Remarks:* If the function fails to meet the postcondition,
|
| 17 |
+
`terminate()` is called [[except.terminate]].
|
| 18 |
+
|
| 19 |
+
[*Note 1*: This can happen if the re-locking of the mutex throws an
|
| 20 |
+
exception. — *end note*]
|
| 21 |
+
|
| 22 |
+
*Ensures:* `lock` is locked by the calling thread.
|
| 23 |
+
|
| 24 |
+
*Throws:* Nothing.
|
| 25 |
+
|
| 26 |
+
``` cpp
|
| 27 |
+
template<class Lock, class Predicate>
|
| 28 |
+
void wait(Lock& lock, Predicate pred);
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
*Effects:* Equivalent to:
|
| 32 |
+
|
| 33 |
+
``` cpp
|
| 34 |
+
while (!pred())
|
| 35 |
+
wait(lock);
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
``` cpp
|
| 39 |
+
template<class Lock, class Clock, class Duration>
|
| 40 |
+
cv_status wait_until(Lock& lock, const chrono::time_point<Clock, Duration>& abs_time);
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
*Effects:*
|
| 44 |
+
|
| 45 |
+
- Atomically calls `lock.unlock()` and blocks on `*this`.
|
| 46 |
+
- When unblocked, calls `lock.lock()` (possibly blocking on the lock)
|
| 47 |
+
and returns.
|
| 48 |
+
- The function will unblock when signaled by a call to `notify_one()`, a
|
| 49 |
+
call to `notify_all()`, expiration of the absolute
|
| 50 |
+
timeout [[thread.req.timing]] specified by `abs_time`, or spuriously.
|
| 51 |
+
- If the function exits via an exception, `lock.lock()` is called prior
|
| 52 |
+
to exiting the function.
|
| 53 |
+
|
| 54 |
+
*Remarks:* If the function fails to meet the postcondition,
|
| 55 |
+
`terminate()` is called [[except.terminate]].
|
| 56 |
+
|
| 57 |
+
[*Note 2*: This can happen if the re-locking of the mutex throws an
|
| 58 |
+
exception. — *end note*]
|
| 59 |
+
|
| 60 |
+
*Ensures:* `lock` is locked by the calling thread.
|
| 61 |
+
|
| 62 |
+
*Returns:* `cv_status::timeout` if the absolute
|
| 63 |
+
timeout [[thread.req.timing]] specified by `abs_time` expired, otherwise
|
| 64 |
+
`cv_status::no_timeout`.
|
| 65 |
+
|
| 66 |
+
*Throws:* Timeout-related exceptions [[thread.req.timing]].
|
| 67 |
+
|
| 68 |
+
``` cpp
|
| 69 |
+
template<class Lock, class Rep, class Period>
|
| 70 |
+
cv_status wait_for(Lock& lock, const chrono::duration<Rep, Period>& rel_time);
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
*Effects:* Equivalent to:
|
| 74 |
+
|
| 75 |
+
``` cpp
|
| 76 |
+
return wait_until(lock, chrono::steady_clock::now() + rel_time);
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
*Returns:* `cv_status::timeout` if the relative
|
| 80 |
+
timeout [[thread.req.timing]] specified by `rel_time` expired, otherwise
|
| 81 |
+
`cv_status::no_timeout`.
|
| 82 |
+
|
| 83 |
+
*Remarks:* If the function fails to meet the postcondition,
|
| 84 |
+
`terminate()` is called [[except.terminate]].
|
| 85 |
+
|
| 86 |
+
[*Note 3*: This can happen if the re-locking of the mutex throws an
|
| 87 |
+
exception. — *end note*]
|
| 88 |
+
|
| 89 |
+
*Ensures:* `lock` is locked by the calling thread.
|
| 90 |
+
|
| 91 |
+
*Throws:* Timeout-related exceptions [[thread.req.timing]].
|
| 92 |
+
|
| 93 |
+
``` cpp
|
| 94 |
+
template<class Lock, class Clock, class Duration, class Predicate>
|
| 95 |
+
bool wait_until(Lock& lock, const chrono::time_point<Clock, Duration>& abs_time, Predicate pred);
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
*Effects:* Equivalent to:
|
| 99 |
+
|
| 100 |
+
``` cpp
|
| 101 |
+
while (!pred())
|
| 102 |
+
if (wait_until(lock, abs_time) == cv_status::timeout)
|
| 103 |
+
return pred();
|
| 104 |
+
return true;
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
[*Note 4*: There is no blocking if `pred()` is initially `true`, or if
|
| 108 |
+
the timeout has already expired. — *end note*]
|
| 109 |
+
|
| 110 |
+
[*Note 5*: The returned value indicates whether the predicate evaluates
|
| 111 |
+
to `true` regardless of whether the timeout was
|
| 112 |
+
triggered. — *end note*]
|
| 113 |
+
|
| 114 |
+
``` cpp
|
| 115 |
+
template<class Lock, class Rep, class Period, class Predicate>
|
| 116 |
+
bool wait_for(Lock& lock, const chrono::duration<Rep, Period>& rel_time, Predicate pred);
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
*Effects:* Equivalent to:
|
| 120 |
+
|
| 121 |
+
``` cpp
|
| 122 |
+
return wait_until(lock, chrono::steady_clock::now() + rel_time, std::move(pred));
|
| 123 |
+
```
|
| 124 |
+
|