tmp/tmp586arjlm/{from.md → to.md}
RENAMED
|
@@ -9,24 +9,37 @@ packaged_task() noexcept;
|
|
| 9 |
``` cpp
|
| 10 |
template<class F>
|
| 11 |
explicit packaged_task(F&& f);
|
| 12 |
```
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
*Constraints:* `remove_cvref_t<F>` is not the same type as
|
| 15 |
`packaged_task<R(ArgTypes...)>`.
|
| 16 |
|
| 17 |
-
*Mandates:* `is_invocable_r_v<R, F&, ArgTypes...>` is `true`.
|
| 18 |
|
| 19 |
-
*Preconditions:*
|
| 20 |
-
|
| 21 |
|
| 22 |
-
*Effects:*
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
*Throws:* Any exceptions thrown by the
|
| 26 |
-
|
| 27 |
-
|
| 28 |
|
| 29 |
``` cpp
|
| 30 |
template<class F> packaged_task(F) -> packaged_task<see below>;
|
| 31 |
```
|
| 32 |
|
|
@@ -136,11 +149,11 @@ where `f` is the stored task and `t`₁`, t`₂`, `…`, t`$_N$ are the values
|
|
| 136 |
in `args...`. If the task returns normally, the return value is stored
|
| 137 |
as the asynchronous result in the shared state of `*this`, otherwise the
|
| 138 |
exception thrown by the task is stored. In either case, this is done
|
| 139 |
without making that state ready [[futures.state]] immediately. Schedules
|
| 140 |
the shared state to be made ready when the current thread exits, after
|
| 141 |
-
all objects
|
| 142 |
thread have been destroyed.
|
| 143 |
|
| 144 |
*Throws:* `future_error` if an error condition occurs.
|
| 145 |
|
| 146 |
*Error conditions:*
|
|
@@ -151,19 +164,26 @@ thread have been destroyed.
|
|
| 151 |
|
| 152 |
``` cpp
|
| 153 |
void reset();
|
| 154 |
```
|
| 155 |
|
| 156 |
-
*Effects:*
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
[*Note 2*: This constructs a new shared state for `*this`. The old
|
| 160 |
state is abandoned [[futures.state]]. — *end note*]
|
| 161 |
|
| 162 |
*Throws:*
|
| 163 |
|
| 164 |
-
-
|
| 165 |
-
- Any exception thrown by the move constructor of the task stored in the
|
| 166 |
-
shared state.
|
| 167 |
- `future_error` with an error condition of `no_state` if `*this` has no
|
| 168 |
shared state.
|
| 169 |
|
|
|
|
| 9 |
``` cpp
|
| 10 |
template<class F>
|
| 11 |
explicit packaged_task(F&& f);
|
| 12 |
```
|
| 13 |
|
| 14 |
+
*Effects:* Equivalent to
|
| 15 |
+
`packaged_task(allocator_arg, allocator<int>(), std::forward<F>(f))`.
|
| 16 |
+
|
| 17 |
+
``` cpp
|
| 18 |
+
template<class F, class Allocator>
|
| 19 |
+
explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
*Constraints:* `remove_cvref_t<F>` is not the same type as
|
| 23 |
`packaged_task<R(ArgTypes...)>`.
|
| 24 |
|
| 25 |
+
*Mandates:* `is_invocable_r_v<R, decay_t<F>&, ArgTypes...>` is `true`.
|
| 26 |
|
| 27 |
+
*Preconditions:* `Allocator` meets the *Cpp17Allocator*
|
| 28 |
+
requirements [[allocator.requirements.general]].
|
| 29 |
|
| 30 |
+
*Effects:* Let `A2` be
|
| 31 |
+
`allocator_traits<Allocator>::rebind_alloc<`*`unspecified`*`>` and let
|
| 32 |
+
`a2` be an object of type `A2` initialized with `A2(a)`. Constructs a
|
| 33 |
+
new `packaged_task` object with a stored task of type `decay_t<F>` and a
|
| 34 |
+
shared state. Initializes the object’s stored task with
|
| 35 |
+
`std::forward<F>(f)`. Uses `a2` to allocate storage for the shared state
|
| 36 |
+
and stores a copy of `a2` in the shared state.
|
| 37 |
|
| 38 |
+
*Throws:* Any exceptions thrown by the initialization of the stored
|
| 39 |
+
task. If storage for the shared state cannot be allocated, any exception
|
| 40 |
+
thrown by `A2::allocate`.
|
| 41 |
|
| 42 |
``` cpp
|
| 43 |
template<class F> packaged_task(F) -> packaged_task<see below>;
|
| 44 |
```
|
| 45 |
|
|
|
|
| 149 |
in `args...`. If the task returns normally, the return value is stored
|
| 150 |
as the asynchronous result in the shared state of `*this`, otherwise the
|
| 151 |
exception thrown by the task is stored. In either case, this is done
|
| 152 |
without making that state ready [[futures.state]] immediately. Schedules
|
| 153 |
the shared state to be made ready when the current thread exits, after
|
| 154 |
+
all objects with thread storage duration associated with the current
|
| 155 |
thread have been destroyed.
|
| 156 |
|
| 157 |
*Throws:* `future_error` if an error condition occurs.
|
| 158 |
|
| 159 |
*Error conditions:*
|
|
|
|
| 164 |
|
| 165 |
``` cpp
|
| 166 |
void reset();
|
| 167 |
```
|
| 168 |
|
| 169 |
+
*Effects:* Equivalent to:
|
| 170 |
+
|
| 171 |
+
``` cpp
|
| 172 |
+
if (!valid()) {
|
| 173 |
+
throw future_error(future_errc::no_state);
|
| 174 |
+
}
|
| 175 |
+
*this = packaged_task(allocator_arg, a, std::move(f));
|
| 176 |
+
```
|
| 177 |
+
|
| 178 |
+
where `f` is the task stored in `*this` and `a` is the allocator stored
|
| 179 |
+
in the shared state.
|
| 180 |
|
| 181 |
[*Note 2*: This constructs a new shared state for `*this`. The old
|
| 182 |
state is abandoned [[futures.state]]. — *end note*]
|
| 183 |
|
| 184 |
*Throws:*
|
| 185 |
|
| 186 |
+
- Any exception thrown by the `packaged_task` constructor.
|
|
|
|
|
|
|
| 187 |
- `future_error` with an error condition of `no_state` if `*this` has no
|
| 188 |
shared state.
|
| 189 |
|