tmp/tmpu2_3w86i/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Waiting and notifying <a id="atomics.wait">[[atomics.wait]]</a>
|
| 2 |
+
|
| 3 |
+
*Atomic waiting operations* and *atomic notifying operations* provide a
|
| 4 |
+
mechanism to wait for the value of an atomic object to change more
|
| 5 |
+
efficiently than can be achieved with polling. An atomic waiting
|
| 6 |
+
operation may block until it is unblocked by an atomic notifying
|
| 7 |
+
operation, according to each function’s effects.
|
| 8 |
+
|
| 9 |
+
[*Note 1*: Programs are not guaranteed to observe transient atomic
|
| 10 |
+
values, an issue known as the A-B-A problem, resulting in continued
|
| 11 |
+
blocking if a condition is only temporarily met. — *end note*]
|
| 12 |
+
|
| 13 |
+
[*Note 2*:
|
| 14 |
+
|
| 15 |
+
The following functions are atomic waiting operations:
|
| 16 |
+
|
| 17 |
+
- `atomic<T>::wait`,
|
| 18 |
+
- `atomic_flag::wait`,
|
| 19 |
+
- `atomic_wait` and `atomic_wait_explicit`,
|
| 20 |
+
- `atomic_flag_wait` and `atomic_flag_wait_explicit`, and
|
| 21 |
+
- `atomic_ref<T>::wait`.
|
| 22 |
+
|
| 23 |
+
— *end note*]
|
| 24 |
+
|
| 25 |
+
[*Note 3*:
|
| 26 |
+
|
| 27 |
+
The following functions are atomic notifying operations:
|
| 28 |
+
|
| 29 |
+
- `atomic<T>::notify_one` and `atomic<T>::notify_all`,
|
| 30 |
+
- `atomic_flag::notify_one` and `atomic_flag::notify_all`,
|
| 31 |
+
- `atomic_notify_one` and `atomic_notify_all`,
|
| 32 |
+
- `atomic_flag_notify_one` and `atomic_flag_notify_all`, and
|
| 33 |
+
- `atomic_ref<T>::notify_one` and `atomic_ref<T>::notify_all`.
|
| 34 |
+
|
| 35 |
+
— *end note*]
|
| 36 |
+
|
| 37 |
+
A call to an atomic waiting operation on an atomic object `M` is
|
| 38 |
+
*eligible to be unblocked* by a call to an atomic notifying operation on
|
| 39 |
+
`M` if there exist side effects `X` and `Y` on `M` such that:
|
| 40 |
+
|
| 41 |
+
- the atomic waiting operation has blocked after observing the result of
|
| 42 |
+
`X`,
|
| 43 |
+
- `X` precedes `Y` in the modification order of `M`, and
|
| 44 |
+
- `Y` happens before the call to the atomic notifying operation.
|
| 45 |
+
|