tmp/tmpvnt201hk/{from.md → to.md}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
### Shared state <a id="futures.state">[[futures.state]]</a>
|
| 2 |
|
| 3 |
-
Many of the classes introduced in
|
| 4 |
-
communicate results. This *shared state* consists of some state
|
| 5 |
information and some (possibly not yet evaluated) *result*, which can be
|
| 6 |
a (possibly void) value or an exception.
|
| 7 |
|
| 8 |
[*Note 1*: Futures, promises, and tasks defined in this clause
|
| 9 |
reference such shared state. — *end note*]
|
|
@@ -14,11 +14,11 @@ compute that result, as used by `async` when `policy` is
|
|
| 14 |
|
| 15 |
An *asynchronous return object* is an object that reads results from a
|
| 16 |
shared state. A *waiting function* of an asynchronous return object is
|
| 17 |
one that potentially blocks to wait for the shared state to be made
|
| 18 |
ready. If a waiting function can return before the state is made ready
|
| 19 |
-
because of a timeout
|
| 20 |
waiting function*, otherwise it is a *non-timed waiting function*.
|
| 21 |
|
| 22 |
An *asynchronous provider* is an object that provides a result to a
|
| 23 |
shared state. The result of a shared state is set by respective
|
| 24 |
functions on the asynchronous provider.
|
|
@@ -61,27 +61,26 @@ A shared state is *ready* only if it holds a value or an exception ready
|
|
| 61 |
for retrieval. Waiting for a shared state to become ready may invoke
|
| 62 |
code to compute the result on the waiting thread if so specified in the
|
| 63 |
description of the class or function that creates the state object.
|
| 64 |
|
| 65 |
Calls to functions that successfully set the stored result of a shared
|
| 66 |
-
state synchronize with
|
| 67 |
successfully detecting the ready state resulting from that setting. The
|
| 68 |
storage of the result (whether normal or exceptional) into the shared
|
| 69 |
-
state synchronizes with
|
| 70 |
-
|
| 71 |
|
| 72 |
Some functions (e.g., `promise::set_value_at_thread_exit`) delay making
|
| 73 |
the shared state ready until the calling thread exits. The destruction
|
| 74 |
-
of each of that thread’s objects with thread storage duration
|
| 75 |
-
[[basic.stc.thread]]
|
| 76 |
-
ready.
|
| 77 |
|
| 78 |
-
Access to the result of the same shared state may conflict
|
| 79 |
-
[[intro.multithread]]
|
| 80 |
|
| 81 |
[*Note 4*: This explicitly specifies that the result of the shared
|
| 82 |
state is visible in the objects that reference this state in the sense
|
| 83 |
-
of data race avoidance
|
| 84 |
-
accesses through references returned by `shared_future::get()`
|
| 85 |
-
[[futures.
|
| 86 |
provide additional synchronization. — *end note*]
|
| 87 |
|
|
|
|
| 1 |
### Shared state <a id="futures.state">[[futures.state]]</a>
|
| 2 |
|
| 3 |
+
Many of the classes introduced in subclause [[futures]] use some state
|
| 4 |
+
to communicate results. This *shared state* consists of some state
|
| 5 |
information and some (possibly not yet evaluated) *result*, which can be
|
| 6 |
a (possibly void) value or an exception.
|
| 7 |
|
| 8 |
[*Note 1*: Futures, promises, and tasks defined in this clause
|
| 9 |
reference such shared state. — *end note*]
|
|
|
|
| 14 |
|
| 15 |
An *asynchronous return object* is an object that reads results from a
|
| 16 |
shared state. A *waiting function* of an asynchronous return object is
|
| 17 |
one that potentially blocks to wait for the shared state to be made
|
| 18 |
ready. If a waiting function can return before the state is made ready
|
| 19 |
+
because of a timeout [[thread.req.lockable]], then it is a *timed
|
| 20 |
waiting function*, otherwise it is a *non-timed waiting function*.
|
| 21 |
|
| 22 |
An *asynchronous provider* is an object that provides a result to a
|
| 23 |
shared state. The result of a shared state is set by respective
|
| 24 |
functions on the asynchronous provider.
|
|
|
|
| 61 |
for retrieval. Waiting for a shared state to become ready may invoke
|
| 62 |
code to compute the result on the waiting thread if so specified in the
|
| 63 |
description of the class or function that creates the state object.
|
| 64 |
|
| 65 |
Calls to functions that successfully set the stored result of a shared
|
| 66 |
+
state synchronize with [[intro.multithread]] calls to functions
|
| 67 |
successfully detecting the ready state resulting from that setting. The
|
| 68 |
storage of the result (whether normal or exceptional) into the shared
|
| 69 |
+
state synchronizes with [[intro.multithread]] the successful return from
|
| 70 |
+
a call to a waiting function on the shared state.
|
| 71 |
|
| 72 |
Some functions (e.g., `promise::set_value_at_thread_exit`) delay making
|
| 73 |
the shared state ready until the calling thread exits. The destruction
|
| 74 |
+
of each of that thread’s objects with thread storage duration
|
| 75 |
+
[[basic.stc.thread]] is sequenced before making that shared state ready.
|
|
|
|
| 76 |
|
| 77 |
+
Access to the result of the same shared state may conflict
|
| 78 |
+
[[intro.multithread]].
|
| 79 |
|
| 80 |
[*Note 4*: This explicitly specifies that the result of the shared
|
| 81 |
state is visible in the objects that reference this state in the sense
|
| 82 |
+
of data race avoidance [[res.on.data.races]]. For example, concurrent
|
| 83 |
+
accesses through references returned by `shared_future::get()`
|
| 84 |
+
[[futures.shared.future]] must either use read-only operations or
|
| 85 |
provide additional synchronization. — *end note*]
|
| 86 |
|