when_all: Conditional Stop Source#2124
Open
RobertLeahy wants to merge 1 commit into
Open
Conversation
This commit implements P4217R1 and P4269R0 by making the following
changes to when_all:
- when_all() is now expression-equivalent to just()
- when_all(s) is now expression-equivalent to auto(s) (i.e. it decay-
copies s)
- The operation state for when_all(s0, ..., sN) now only contains a stop
source if:
- Any of s0, ..., sN can complete unsuccessfully in the ambient
environment, or
- Decay-copying the values sent by any of s0, ... sN can throw an
exception
The last bullet prevents when_all from "hallucinating" set_stopped:
Previously when_all unconditionally managed a stop source, and injected
stop tokens therefrom into its children. Consider when_all(s0, s1) where
s0 and s1:
- Have only set_value_t() as a completion signature in the ambient
environment, and
- Have set_value_t() and set_stopped_t() as completion signatures in an
environment with an inplace_stop_token
when_all(s0, s1) plainly does not need a stop source because neither s0
nor s1 will ever complete unsuccessfully (see bullet one above). However
when_all(s0, s1) would previously create a stop source anyway, and
inject tokens therefrom into s0 and s1. This would cause s0 and s1 to
report an additional stopped completion (see bullet two above) which
would cause when_all to report set_value_t() and set_stopped_t() as
completion signatures even though the latter is never actually emitted
(because s0 and s1 don't fail except by stop request, but the only way
for a stop request to be emitted is for either of them to fail).
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.
This commit implements P4217R1 and P4269R0 by making the following changes to when_all:
The last bullet prevents when_all from "hallucinating" set_stopped: Previously when_all unconditionally managed a stop source, and injected stop tokens therefrom into its children. Consider when_all(s0, s1) where s0 and s1:
when_all(s0, s1) plainly does not need a stop source because neither s0 nor s1 will ever complete unsuccessfully (see bullet one above). However when_all(s0, s1) would previously create a stop source anyway, and inject tokens therefrom into s0 and s1. This would cause s0 and s1 to report an additional stopped completion (see bullet two above) which would cause when_all to report set_value_t() and set_stopped_t() as completion signatures even though the latter is never actually emitted (because s0 and s1 don't fail except by stop request, but the only way for a stop request to be emitted is for either of them to fail).