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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Class `task::promise_type` <a id="task.promise">[[task.promise]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std::execution {
|
| 5 |
+
template<class T, class Environment>
|
| 6 |
+
class task<T, Environment>::promise_type {
|
| 7 |
+
public:
|
| 8 |
+
template<class... Args>
|
| 9 |
+
promise_type(const Args&... args);
|
| 10 |
+
|
| 11 |
+
task get_return_object() noexcept;
|
| 12 |
+
|
| 13 |
+
auto initial_suspend() noexcept;
|
| 14 |
+
auto final_suspend() noexcept;
|
| 15 |
+
|
| 16 |
+
void uncaught_exception();
|
| 17 |
+
coroutine_handle<> unhandled_stopped();
|
| 18 |
+
|
| 19 |
+
void return_void(); // present only if is_void_v<T> is true
|
| 20 |
+
template<class V>
|
| 21 |
+
void return_value(V&& value); // present only if is_void_v<T> is false
|
| 22 |
+
|
| 23 |
+
template<class E>
|
| 24 |
+
unspecified yield_value(with_error<E> error);
|
| 25 |
+
|
| 26 |
+
template<class A>
|
| 27 |
+
auto await_transform(A&& a);
|
| 28 |
+
template<class Sch>
|
| 29 |
+
auto await_transform(change_coroutine_scheduler<Sch> sch);
|
| 30 |
+
|
| 31 |
+
unspecified get_env() const noexcept;
|
| 32 |
+
|
| 33 |
+
template<class... Args>
|
| 34 |
+
void* operator new(size_t size, Args&&... args);
|
| 35 |
+
|
| 36 |
+
void operator delete(void* pointer, size_t size) noexcept;
|
| 37 |
+
|
| 38 |
+
private:
|
| 39 |
+
using error-variant = see belownc; // exposition only
|
| 40 |
+
|
| 41 |
+
allocator_type alloc; // exposition only
|
| 42 |
+
stop_source_type source; // exposition only
|
| 43 |
+
stop_token_type token; // exposition only
|
| 44 |
+
optional<T> result; // exposition only; present only if is_void_v<T> is false
|
| 45 |
+
error-variant errors; // exposition only
|
| 46 |
+
};
|
| 47 |
+
}
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
Let `prom` be an object of `promise_type` and let `tsk` be the `task`
|
| 51 |
+
object created by `prom.get_return_object()`. The description below
|
| 52 |
+
refers to objects `STATE(prom)`, `RCVR(prom)`, and `SCHED(prom)`
|
| 53 |
+
associated with `tsk` during evaluation of `task::state<Rcvr>::start`
|
| 54 |
+
for some receiver `Rcvr`.
|
| 55 |
+
|
| 56 |
+
*`error-variant`* is a `variant<monostate,
|
| 57 |
+
remove_cvref_t<E>...>`, with duplicate types removed, where `E...` are
|
| 58 |
+
the parameter types of the template arguments of the specialization of
|
| 59 |
+
`execution::completion_signatures` denoted by `error_types`.
|
| 60 |
+
|
| 61 |
+
``` cpp
|
| 62 |
+
template<class... Args>
|
| 63 |
+
promise_type(const Args&... args);
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
*Mandates:* The first parameter of type `allocator_arg_t` (if any) is
|
| 67 |
+
not the last parameter.
|
| 68 |
+
|
| 69 |
+
*Effects:* If `Args` contains an element of type `allocator_arg_t` then
|
| 70 |
+
*alloc* is initialized with the corresponding next element of `args`.
|
| 71 |
+
Otherwise, *alloc* is initialized with `allocator_type()`.
|
| 72 |
+
|
| 73 |
+
``` cpp
|
| 74 |
+
task get_return_object() noexcept;
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
*Returns:* A `task` object whose member *handle* is
|
| 78 |
+
`coroutine_handle<promise_type>::from_promise(*this)`.
|
| 79 |
+
|
| 80 |
+
``` cpp
|
| 81 |
+
auto initial_suspend() noexcept;
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
*Returns:* An awaitable object of unspecified type [[expr.await]] whose
|
| 85 |
+
member functions arrange for
|
| 86 |
+
|
| 87 |
+
- the calling coroutine to be suspended,
|
| 88 |
+
- the coroutine to be resumed on an execution agent of the execution
|
| 89 |
+
resource associated with *`SCHED`*`(*this)`.
|
| 90 |
+
|
| 91 |
+
``` cpp
|
| 92 |
+
auto final_suspend() noexcept;
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
*Returns:* An awaitable object of unspecified type [[expr.await]] whose
|
| 96 |
+
member functions arrange for the completion of the asynchronous
|
| 97 |
+
operation associated with *`STATE`*`(*this)` by invoking:
|
| 98 |
+
|
| 99 |
+
- `set_error(std::move(`*`RCVR`*`(*this)), std::move(e))` if
|
| 100 |
+
*`errors`*`.index()` is greater than zero and `e` is the value held by
|
| 101 |
+
*errors*, otherwise
|
| 102 |
+
- `set_value(std::move(`*`RCVR`*`(*this)))` if `is_void<T>` is `true`,
|
| 103 |
+
and otherwise
|
| 104 |
+
- `set_value(std::move(`*`RCVR`*`(*this)), *`*`result`*`)`.
|
| 105 |
+
|
| 106 |
+
``` cpp
|
| 107 |
+
template<class Err>
|
| 108 |
+
auto yield_value(with_error<Err> err);
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
*Mandates:* `std::move(err.error)` is convertible to exactly one of the
|
| 112 |
+
`set_error_t` argument types of `error_types`. Let *`Cerr`* be that
|
| 113 |
+
type.
|
| 114 |
+
|
| 115 |
+
*Returns:* An awaitable object of unspecified type [[expr.await]] whose
|
| 116 |
+
member functions arrange for the calling coroutine to be suspended and
|
| 117 |
+
then completes the asynchronous operation associated with
|
| 118 |
+
*`STATE`*`(*this)` by invoking
|
| 119 |
+
`set_error(std::move(`*`RCVR`*`(*this)), `*`Cerr`*`(std::move(err.error)))`.
|
| 120 |
+
|
| 121 |
+
``` cpp
|
| 122 |
+
template<sender Sender>
|
| 123 |
+
auto await_transform(Sender&& sndr) noexcept;
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
*Returns:* If `same_as<inline_scheduler, scheduler_type>` is `true`
|
| 127 |
+
returns `as_awaitable(std::forward<Sender>(sndr), *this)`; otherwise
|
| 128 |
+
returns
|
| 129 |
+
`as_awaitable(affine_on(std::forward<Sender>(sndr), `*`SCHED`*`(*this)), *this)`.
|
| 130 |
+
|
| 131 |
+
``` cpp
|
| 132 |
+
template<class Sch>
|
| 133 |
+
auto await_transform(change_coroutine_scheduler<Sch> sch) noexcept;
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
*Effects:* Equivalent to:
|
| 137 |
+
|
| 138 |
+
``` cpp
|
| 139 |
+
return await_transform(just(exchange(SCHED(*this), scheduler_type(sch.scheduler))), *this);
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
``` cpp
|
| 143 |
+
void uncaught_exception();
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+
*Effects:* If the signature `set_error_t(exception_ptr)` is not an
|
| 147 |
+
element of `error_types`, calls `terminate()` [[except.terminate]].
|
| 148 |
+
Otherwise, stores `current_exception()` into *errors*.
|
| 149 |
+
|
| 150 |
+
``` cpp
|
| 151 |
+
coroutine_handle<> unhandled_stopped();
|
| 152 |
+
```
|
| 153 |
+
|
| 154 |
+
*Effects:* Completes the asynchronous operation associated with
|
| 155 |
+
*`STATE`*`(*this)` by invoking
|
| 156 |
+
`set_stopped(std::move(`*`RCVR`*`(*this)))`.
|
| 157 |
+
|
| 158 |
+
*Returns:* `noop_coroutine()`.
|
| 159 |
+
|
| 160 |
+
``` cpp
|
| 161 |
+
unspecified get_env() const noexcept;
|
| 162 |
+
```
|
| 163 |
+
|
| 164 |
+
*Returns:* An object `env` such that queries are forwarded as follows:
|
| 165 |
+
|
| 166 |
+
- `env.query(get_scheduler)` returns
|
| 167 |
+
`scheduler_type(`*`SCHED`*`(*this))`.
|
| 168 |
+
- `env.query(get_allocator)` returns *alloc*.
|
| 169 |
+
- `env.query(get_stop_token)` returns *token*.
|
| 170 |
+
- For any other query `q` and arguments `a...` a call to
|
| 171 |
+
`env.query(q, a...)` returns *`STATE`*`(*this)`.
|
| 172 |
+
`environment.query(q, a...)` if this expression is well-formed and
|
| 173 |
+
`forwarding_query(q)` is well-formed and is `true`. Otherwise
|
| 174 |
+
`env.query(q, a...)` is ill-formed.
|
| 175 |
+
|
| 176 |
+
``` cpp
|
| 177 |
+
template<class... Args>
|
| 178 |
+
void* operator new(size_t size, const Args&... args);
|
| 179 |
+
```
|
| 180 |
+
|
| 181 |
+
If there is no parameter with type `allocator_arg_t` then let `alloc` be
|
| 182 |
+
`allocator_type()`. Otherwise, let `arg_next` be the parameter following
|
| 183 |
+
the first `allocator_arg_t` parameter, and let `alloc` be
|
| 184 |
+
`allocator_type(arg_next)`. Let `PAlloc` be
|
| 185 |
+
`allocator_traits<allocator_type>::template rebind_alloc<U>`, where `U`
|
| 186 |
+
is an unspecified type whose size and alignment are both
|
| 187 |
+
\_\_STDCPP_DEFAULT_NEW_ALIGNMENT\_\_.
|
| 188 |
+
|
| 189 |
+
*Mandates:*
|
| 190 |
+
|
| 191 |
+
- The first parameter of type `allocator_arg_t` (if any) is not the last
|
| 192 |
+
parameter.
|
| 193 |
+
- `allocator_type(arg_next)` is a valid expression if there is a
|
| 194 |
+
parameter of type `allocator_arg_t`.
|
| 195 |
+
- `allocator_traits<PAlloc>::pointer` is a pointer type.
|
| 196 |
+
|
| 197 |
+
*Effects:* Initializes an allocator `palloc` of type `PAlloc` with
|
| 198 |
+
`alloc`. Uses `palloc` to allocate storage for the smallest array of `U`
|
| 199 |
+
sufficient to provide storage for a coroutine state of size `size`, and
|
| 200 |
+
unspecified additional state necessary to ensure that `operator delete`
|
| 201 |
+
can later deallocate this memory block with an allocator equal to
|
| 202 |
+
`palloc`.
|
| 203 |
+
|
| 204 |
+
*Returns:* A pointer to the allocated storage.
|
| 205 |
+
|
| 206 |
+
``` cpp
|
| 207 |
+
void operator delete(void* pointer, size_t size) noexcept;
|
| 208 |
+
```
|
| 209 |
+
|
| 210 |
+
*Preconditions:* `pointer` was returned from an invocation of the above
|
| 211 |
+
overload of `operator new` with a size argument equal to `size`.
|
| 212 |
+
|
| 213 |
+
*Effects:* Deallocates the storage pointed to by `pointer` using an
|
| 214 |
+
allocator equal to that used to allocate it.
|
| 215 |
+
|