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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Class template `shared_future` <a id="futures.shared.future">[[futures.shared.future]]</a>
|
| 2 |
+
|
| 3 |
+
The class template `shared_future` defines a type for asynchronous
|
| 4 |
+
return objects which may share their shared state with other
|
| 5 |
+
asynchronous return objects. A default-constructed `shared_future`
|
| 6 |
+
object has no shared state. A `shared_future` object with shared state
|
| 7 |
+
can be created by conversion from a `future` object and shares its
|
| 8 |
+
shared state with the original asynchronous provider [[futures.state]]
|
| 9 |
+
of the shared state. The result (value or exception) of a
|
| 10 |
+
`shared_future` object can be set by calling a respective function on an
|
| 11 |
+
object that shares the same shared state.
|
| 12 |
+
|
| 13 |
+
[*Note 1*: Member functions of `shared_future` do not synchronize with
|
| 14 |
+
themselves, but they synchronize with the shared state. — *end note*]
|
| 15 |
+
|
| 16 |
+
The effect of calling any member function other than the destructor, the
|
| 17 |
+
move-assignment operator, the copy-assignment operator, or `valid()` on
|
| 18 |
+
a `shared_future` object for which `valid() == false` is undefined.
|
| 19 |
+
|
| 20 |
+
[*Note 2*: It is valid to copy or move from a `shared_future` object
|
| 21 |
+
for which `valid()` is `false`. — *end note*]
|
| 22 |
+
|
| 23 |
+
[*Note 3*: Implementations should detect this case and throw an object
|
| 24 |
+
of type `future_error` with an error condition of
|
| 25 |
+
`future_errc::no_state`. — *end note*]
|
| 26 |
+
|
| 27 |
+
``` cpp
|
| 28 |
+
namespace std {
|
| 29 |
+
template<class R>
|
| 30 |
+
class shared_future {
|
| 31 |
+
public:
|
| 32 |
+
shared_future() noexcept;
|
| 33 |
+
shared_future(const shared_future& rhs) noexcept;
|
| 34 |
+
shared_future(future<R>&&) noexcept;
|
| 35 |
+
shared_future(shared_future&& rhs) noexcept;
|
| 36 |
+
~shared_future();
|
| 37 |
+
shared_future& operator=(const shared_future& rhs) noexcept;
|
| 38 |
+
shared_future& operator=(shared_future&& rhs) noexcept;
|
| 39 |
+
|
| 40 |
+
// retrieving the value
|
| 41 |
+
see below get() const;
|
| 42 |
+
|
| 43 |
+
// functions to check state
|
| 44 |
+
bool valid() const noexcept;
|
| 45 |
+
|
| 46 |
+
void wait() const;
|
| 47 |
+
template<class Rep, class Period>
|
| 48 |
+
future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
|
| 49 |
+
template<class Clock, class Duration>
|
| 50 |
+
future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
|
| 51 |
+
};
|
| 52 |
+
}
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
The implementation provides the template `shared_future` and two
|
| 56 |
+
specializations, `shared_future<R&>` and `shared_future<void>`. These
|
| 57 |
+
differ only in the return type and return value of the member function
|
| 58 |
+
`get`, as set out in its description, below.
|
| 59 |
+
|
| 60 |
+
``` cpp
|
| 61 |
+
shared_future() noexcept;
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
*Effects:* The object does not refer to a shared state.
|
| 65 |
+
|
| 66 |
+
*Ensures:* `valid() == false`.
|
| 67 |
+
|
| 68 |
+
``` cpp
|
| 69 |
+
shared_future(const shared_future& rhs) noexcept;
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
*Effects:* The object refers to the same shared state as `rhs` (if any).
|
| 73 |
+
|
| 74 |
+
*Ensures:* `valid()` returns the same value as `rhs.valid()`.
|
| 75 |
+
|
| 76 |
+
``` cpp
|
| 77 |
+
shared_future(future<R>&& rhs) noexcept;
|
| 78 |
+
shared_future(shared_future&& rhs) noexcept;
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
*Effects:* Move constructs a `shared_future` object that refers to the
|
| 82 |
+
shared state that was originally referred to by `rhs` (if any).
|
| 83 |
+
|
| 84 |
+
*Ensures:*
|
| 85 |
+
|
| 86 |
+
- `valid()` returns the same value as `rhs.valid()` returned prior to
|
| 87 |
+
the constructor invocation.
|
| 88 |
+
- `rhs.valid() == false`.
|
| 89 |
+
|
| 90 |
+
``` cpp
|
| 91 |
+
~shared_future();
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
*Effects:*
|
| 95 |
+
|
| 96 |
+
- Releases any shared state [[futures.state]];
|
| 97 |
+
- destroys `*this`.
|
| 98 |
+
|
| 99 |
+
``` cpp
|
| 100 |
+
shared_future& operator=(shared_future&& rhs) noexcept;
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
*Effects:*
|
| 104 |
+
|
| 105 |
+
- Releases any shared state [[futures.state]];
|
| 106 |
+
- move assigns the contents of `rhs` to `*this`.
|
| 107 |
+
|
| 108 |
+
*Ensures:*
|
| 109 |
+
|
| 110 |
+
- `valid()` returns the same value as `rhs.valid()` returned prior to
|
| 111 |
+
the assignment.
|
| 112 |
+
- `rhs.valid() == false`.
|
| 113 |
+
|
| 114 |
+
``` cpp
|
| 115 |
+
shared_future& operator=(const shared_future& rhs) noexcept;
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
*Effects:*
|
| 119 |
+
|
| 120 |
+
- Releases any shared state [[futures.state]];
|
| 121 |
+
- assigns the contents of `rhs` to `*this`. \[*Note 4*: As a result,
|
| 122 |
+
`*this` refers to the same shared state as `rhs` (if
|
| 123 |
+
any). — *end note*]
|
| 124 |
+
|
| 125 |
+
*Ensures:* `valid() == rhs.valid()`.
|
| 126 |
+
|
| 127 |
+
``` cpp
|
| 128 |
+
const R& shared_future::get() const;
|
| 129 |
+
R& shared_future<R&>::get() const;
|
| 130 |
+
void shared_future<void>::get() const;
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
[*Note 1*: As described above, the template and its two required
|
| 134 |
+
specializations differ only in the return type and return value of the
|
| 135 |
+
member function `get`. — *end note*]
|
| 136 |
+
|
| 137 |
+
[*Note 2*: Access to a value object stored in the shared state is
|
| 138 |
+
unsynchronized, so programmers should apply only those operations on `R`
|
| 139 |
+
that do not introduce a data race [[intro.multithread]]. — *end note*]
|
| 140 |
+
|
| 141 |
+
*Effects:* `wait()`s until the shared state is ready, then retrieves the
|
| 142 |
+
value stored in the shared state.
|
| 143 |
+
|
| 144 |
+
*Returns:*
|
| 145 |
+
|
| 146 |
+
- `shared_future::get()` returns a const reference to the value stored
|
| 147 |
+
in the object’s shared state. \[*Note 5*: Access through that
|
| 148 |
+
reference after the shared state has been destroyed produces undefined
|
| 149 |
+
behavior; this can be avoided by not storing the reference in any
|
| 150 |
+
storage with a greater lifetime than the `shared_future` object that
|
| 151 |
+
returned the reference. — *end note*]
|
| 152 |
+
- `shared_future<R&>::get()` returns the reference stored as value in
|
| 153 |
+
the object’s shared state.
|
| 154 |
+
- `shared_future<void>::get()` returns nothing.
|
| 155 |
+
|
| 156 |
+
*Throws:* The stored exception, if an exception was stored in the shared
|
| 157 |
+
state.
|
| 158 |
+
|
| 159 |
+
``` cpp
|
| 160 |
+
bool valid() const noexcept;
|
| 161 |
+
```
|
| 162 |
+
|
| 163 |
+
*Returns:* `true` only if `*this` refers to a shared state.
|
| 164 |
+
|
| 165 |
+
``` cpp
|
| 166 |
+
void wait() const;
|
| 167 |
+
```
|
| 168 |
+
|
| 169 |
+
*Effects:* Blocks until the shared state is ready.
|
| 170 |
+
|
| 171 |
+
``` cpp
|
| 172 |
+
template<class Rep, class Period>
|
| 173 |
+
future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
|
| 174 |
+
```
|
| 175 |
+
|
| 176 |
+
*Effects:* None if the shared state contains a deferred
|
| 177 |
+
function [[futures.async]], otherwise blocks until the shared state is
|
| 178 |
+
ready or until the relative timeout [[thread.req.timing]] specified by
|
| 179 |
+
`rel_time` has expired.
|
| 180 |
+
|
| 181 |
+
*Returns:*
|
| 182 |
+
|
| 183 |
+
- `future_status::deferred` if the shared state contains a deferred
|
| 184 |
+
function.
|
| 185 |
+
- `future_status::ready` if the shared state is ready.
|
| 186 |
+
- `future_status::timeout` if the function is returning because the
|
| 187 |
+
relative timeout [[thread.req.timing]] specified by `rel_time` has
|
| 188 |
+
expired.
|
| 189 |
+
|
| 190 |
+
*Throws:* timeout-related exceptions [[thread.req.timing]].
|
| 191 |
+
|
| 192 |
+
``` cpp
|
| 193 |
+
template<class Clock, class Duration>
|
| 194 |
+
future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
|
| 195 |
+
```
|
| 196 |
+
|
| 197 |
+
*Effects:* None if the shared state contains a deferred
|
| 198 |
+
function [[futures.async]], otherwise blocks until the shared state is
|
| 199 |
+
ready or until the absolute timeout [[thread.req.timing]] specified by
|
| 200 |
+
`abs_time` has expired.
|
| 201 |
+
|
| 202 |
+
*Returns:*
|
| 203 |
+
|
| 204 |
+
- `future_status::deferred` if the shared state contains a deferred
|
| 205 |
+
function.
|
| 206 |
+
- `future_status::ready` if the shared state is ready.
|
| 207 |
+
- `future_status::timeout` if the function is returning because the
|
| 208 |
+
absolute timeout [[thread.req.timing]] specified by `abs_time` has
|
| 209 |
+
expired.
|
| 210 |
+
|
| 211 |
+
*Throws:* timeout-related exceptions [[thread.req.timing]].
|
| 212 |
+
|