task: co_return with_error(...) & with_stopped - #2154
Open
RobertLeahy wants to merge 3 commits into
Open
Conversation
The standard specifies that std::execution::task shall destroy the coroutine frame before sending set_stopped to the receiver in the case of unhandled_stopped: The asynchronous operation is completed by first destroying the coroutine frame [...] and then invoking set_stopped(std::move( st.rcvr)). STDEXEC::task previously belied this, instead destroying the coroutine frame sometime after the dispatch of set_stopped. Added a reproducing unit test and corrected.
The standard specifies that co_yield with_error(e) is valid if e is convertible to one of the task's error types: Mandates: std::move(err.error) is convertible to exactly one of the set_error_t argument types of error_types. STDEXEC::task previously belied this instead requiring that e be exactly one of the error types (rather than convertible to exactly one such type). Fixed and added a reproducing unit test.
ericniebler
approved these changes
Aug 2, 2026
Collaborator
|
/ok to test fdf37b8 |
Implemented P4282 by enhancing task as follows: - co_yield can now be used directly to send set_stopped using the new with_stopped tag - co_return can now be used with with_error and with_stopped to send set_error or set_stopped, respectively Note that the co_return functionality requires a compiler which implements P3950 (adopted into the C++29 working draft in Brno) when used with a task<void>.
RobertLeahy
force-pushed
the
p4282_20260801
branch
from
August 2, 2026 22:11
fdf37b8 to
957991f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two bugfixes and implementation of of P4282R1 Away From
co_yieldForstd::execution::task.Note that newly-added
co_returnfunctionality fortask<void>requires a compiler which provides P3950R1return_value&return_voidAre Not Mutually Exclusive.