From Jason Turner

[task.state]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmprjnkbk3s/{from.md → to.md} +88 -0
tmp/tmprjnkbk3s/{from.md → to.md} RENAMED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class template `task::state` <a id="task.state">[[task.state]]</a>
2
+
3
+ ``` cpp
4
+ namespace std::execution {
5
+ template<class T, class Environment>
6
+ template<receiver Rcvr>
7
+ class task<T, Environment>::state { // exposition only
8
+ public:
9
+ using operation_state_concept = operation_state_t;
10
+
11
+ template<class R>
12
+ state(coroutine_handle<promise_type> h, R&& rr);
13
+
14
+ ~state();
15
+
16
+ void start() & noexcept;
17
+
18
+ private:
19
+ using own-env-t = see belownc; // exposition only
20
+ coroutine_handle<promise_type> handle; // exposition only
21
+ remove_cvref_t<Rcvr> rcvr; // exposition only
22
+ own-env-t own-env; // exposition only
23
+ Environment environment; // exposition only
24
+ };
25
+ }
26
+ ```
27
+
28
+ The type *`own-env-t`* is `Environment::template
29
+ env_type<decltype(get_env({}declval{}<Rcvr>({}))){}>` if that
30
+ *qualified-id* is valid and denotes a type, `env<>` otherwise.
31
+
32
+ ``` cpp
33
+ template<class R>
34
+ state(coroutine_handle<promise_type> h, R&& rr);
35
+ ```
36
+
37
+ *Effects:* Initializes
38
+
39
+ - *handle* with `std::move(h)`;
40
+ - *rcvr* with `std::forward<R>(rr)`;
41
+ - *own-env* with *`own-env-t`*`(get_env(`*`rcvr`*`))` if that expression
42
+ is valid and *`own-env-t`*`()` otherwise. If neither of these
43
+ expressions is valid, the program is ill-formed.
44
+ - *environment* with `Environment(`*`own-env`*`)` if that expression is
45
+ valid, otherwise `Environment(get_env(`*`rcvr`*`))` if this expression
46
+ is valid, otherwise `Environment()`. If neither of these expressions
47
+ is valid, the program is ill-formed.
48
+
49
+ ``` cpp
50
+ ~state();
51
+ ```
52
+
53
+ *Effects:* Equivalent to:
54
+
55
+ ``` cpp
56
+ if (handle)
57
+ handle.destroy();
58
+ ```
59
+
60
+ ``` cpp
61
+ void start() & noexcept;
62
+ ```
63
+
64
+ *Effects:* Let *`prom`* be the object *`handle`*`.promise()`. Associates
65
+ *`STATE`*`(`*`prom`*`)`, *`RCVR`*`(`*`prom`*`)`, and
66
+ *`SCHED`*`(`*`prom`*`)` with `*this` as follows:
67
+
68
+ - *`STATE`*`(`*`prom`*`)` is `*this`.
69
+ - *`RCVR`*`(`*`prom`*`)` is *rcvr*.
70
+ - *`SCHED`*`(`*`prom`*`)` is the object initialized with
71
+ `scheduler_type(get_scheduler(get_env(`*`rcvr`*`)))` if that
72
+ expression is valid and `scheduler_type()` otherwise. If neither of
73
+ these expressions is valid, the program is ill-formed.
74
+
75
+ Let *`st`* be `get_stop_token(get_env(`*`rcvr`*`))`. Initializes
76
+ *`prom`*`.`*`token`* and *`prom`*`.`*`source`* such that
77
+
78
+ - *`prom`*`.`*`token`*`.stop_requested()` returns
79
+ *`st`*`.stop_requested()`;
80
+ - *`prom`*`.`*`token`*`.stop_possible()` returns
81
+ *`st`*`.stop_possible()`; and
82
+ - for types `Fn` and `Init` such that both `invocable<Fn>` and
83
+ `constructible_from<Fn, Init>` are modeled,
84
+ `stop_token_type::callback_type<Fn>` models
85
+ `stoppable-callback-for<Fn, stop_token_type, Init>`.
86
+
87
+ After that invokes *`handle`*`.resume()`.
88
+