Commit f2449df
committed
exec::repeat_effect: No set_value Completion Signature
exec::repeat_effect_until provides the asynchronous analogue of an until
loop (i.e. a while not loop). The algorithm repeatedly:
1. Connects the wrapped sender, and then
2. Starts the resulting operation state and allows it to run
Until the result is true (or converts to true) at which point the
asynchronous loop ends and the overall asynchronous operation ends with
a nullary set_value completion signal.
exec::repeat_effect on the other hand provides the asynchronous analogue
of an infinite loop. Notably unlike until loops infinite loops never
complete successfully. Despite this exec::repeat_effect(snd) was
previously implemented as being equivalent to:
exec::repeat_effect_until(snd | stdexec::then([] noexcept {
return false;
}))
Note that this means that the resulting sender advertised stdexec::
set_value_t() as a completion signature, but never actually sent it
(because the sender wrapped by exec::repeat_effect_until always
connected to form an asynchronous operation which sends false).
Addressed the above by updating exec::repeat_effect_until such that when
its child operation completes it examines sent type T:
- If std::remove_cvref_t<T>::value is a constant expression which
evaluates to true, unconditionally completes the operation with a
nullary set_value completion signature (i.e. the runtime branch is
eliminated without relying on the optimizer), otherwise
- If T satisfies the conditions laid out above except that the constant
expression evaluates to false, unconditionally starts the next loop
(i.e. the call to stdexec::set_value is not emitted and therefore the
operation's receiver need not support receipt thereof), otherwise
- Proceeds as before this change
Moreover updated the computation of exec::repeat_effect_until's
completion signatures to reflect the above: That is, if all set_value
completions of the child sender send a type which falls under the second
bullet above, no set_value completion signature will be advertised from
exec::repeat_effect_until.
Lastly updated the sender synthesized by exec::repeat_effect such that
it sends std::false_type rather than bool, thereby causing it to no
longer advertise set_value completion signatures (or require handling
thereof from its receiver).1 parent c03da7a commit f2449df
File tree
2 files changed
+35
-8
lines changed- include/exec
- test/exec
2 files changed
+35
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
| |||
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
123 | | - | |
124 | | - | |
| 126 | + | |
125 | 127 | | |
126 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
127 | 135 | | |
128 | 136 | | |
129 | 137 | | |
| |||
163 | 171 | | |
164 | 172 | | |
165 | 173 | | |
166 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
167 | 178 | | |
168 | 179 | | |
169 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
170 | 184 | | |
171 | 185 | | |
172 | 186 | | |
173 | 187 | | |
174 | 188 | | |
175 | | - | |
| 189 | + | |
| 190 | + | |
176 | 191 | | |
177 | 192 | | |
178 | 193 | | |
| |||
222 | 237 | | |
223 | 238 | | |
224 | 239 | | |
225 | | - | |
226 | | - | |
| 240 | + | |
| 241 | + | |
227 | 242 | | |
228 | 243 | | |
229 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
192 | 200 | | |
193 | 201 | | |
194 | 202 | | |
195 | 203 | | |
196 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
197 | 209 | | |
198 | 210 | | |
199 | 211 | | |
| |||
202 | 214 | | |
203 | 215 | | |
204 | 216 | | |
205 | | - | |
| 217 | + | |
206 | 218 | | |
207 | 219 | | |
208 | 220 | | |
| |||
0 commit comments