On 9/7/24 6:45 AM, Iain Sandoe wrote:
As noted in the PR the action of the existing implementation was to treat a false value from await_suspend () as equivalent to "do not suspend". Actually it needs to be the equivalent of "resume" - and we need to restart the dispatcher - since the await_suspend() body could have already resumed the coroutine. See also https://github.com/cplusplus/CWG/issues/601 (NAD) for more discussion.
I'm having trouble wrapping my head around this stuff, so I'll take your word for it. :) It would be nice to have more full pseudocode.
+ /* Finish the destory dispatcher. */
Typo.
+ /* Build the dispatcher: + if (resume index is odd) + { + switch (resume index) + case 1: + goto cleanup. + case ... odd suspension point number + .CO_ACTOR (... odd suspension point number) + break; + default: + break; + } + else + { + coro.restart.dispatch: + case 0: + goto start. + case ... even suspension point number + .CO_ACTOR (... even suspension point number) + break; + default: + break; + } + we should not get here unless something is broken badly. + __builtin_trap (); +*/
Maybe mention in this that the odd case is destroy and the even case is resume? Why is it useful to have two separate switches when they have the same default: behavior?
+ /* For the case of a boolean await_resume () that returns 'true' we should + restart the dispatch, since we cannot know if additional resumes were + executed from within the await_resume function. */
Do you mean await_suspend here? OK with at least the typo fixed. Jason