Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is a coroutine considered suspend after evaluating the await-suspend expression for the final suspend point #4569

Open
xmh0511 opened this issue Mar 31, 2021 · 3 comments
Assignees

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Mar 31, 2021

Assume the operand of the expression co_await promise.final_suspend() has std::always_suspend type. That means after evaluating the associated await-ready expression, the coroutine should be considered in a suspending state and then transfer the control to the caller or resumer after evaluating the await-suspend expression.

If the result of await-ready is false, the coroutine is considered suspended.

Then invoking resume() for the coroutine will result in a crash in most major implementations(GCC, clang). But, invoking destroy() is ok. The current draft is underspecified for what the status is.

There are only little hints in section [support.coroutine]
support.coroutine#coroutine.handle.observers-3

true if the coroutine is suspended at its final suspend point, otherwise false.

support.coroutine#coroutine.handle.resumption-2

Preconditions: The coroutine is not suspended at its final suspend point.

If merely according to what [expr.await#5] says, the coroutine should be considered in a suspending status. IIUC, the preconditions above intend to state that when calling resume for a coroutine after evaluating the associated await-suspend expression for the final suspend point, the coroutine is as if it's not in suspending status at this point. Should we make the rule be a normative rule defined at [dcl.fct.def.coroutine]?

@xmh0511 xmh0511 changed the title Is a corotine considered suspend after evaluating the await-suspend expression for the final suspend Is a corotine considered suspend after evaluating the await-suspend expression for the final suspend point Mar 31, 2021
@xmh0511 xmh0511 changed the title Is a corotine considered suspend after evaluating the await-suspend expression for the final suspend point Is a coroutine considered suspend after evaluating the await-suspend expression for the final suspend point Mar 31, 2021
@jensmaurer
Copy link
Member

Is this editorial?

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Apr 10, 2021
@xmh0511
Copy link
Contributor Author

xmh0511 commented Apr 11, 2021

Is this editorial?

Might be not. I just think we should describe more than the current for the special final suspend point. The suspend at that point is different from others.

@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Apr 16, 2021
@jensmaurer
Copy link
Member

Editorial meeting 2021-04-16: @tkoeppe will clarify with the submitter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants