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

Should when_all and split check the receiver's stop token for stop_requested() and call set_stopped? #295

Open
jiixyj opened this issue Oct 18, 2024 · 0 comments
Assignees

Comments

@jiixyj
Copy link

jiixyj commented Oct 18, 2024

when_all's start function executes this code:

  state.on_stop.emplace(
    get_stop_token(get_env(rcvr)),
    on-stop-request{state.stop_src});
  if (state.stop_src.stop_requested()) {
    state.on_stop.reset();
    set_stopped(std::move(rcvr));
  } else {
    (start(ops), ...);
  }

...so it checks the receivers stop token and calls set_stopped if this is set. The problem with this is that I as the user cannot really disable this behavior. If I wrap the when_all in unstoppable the whole thing cannot be stopped any longer. But I might want the child operations to react to cancellation requests from the outside.

Opting into this behavior is much easier, by wrapping the when_all sender into a sender that does this checking.

This makes it sometimes impossible to use when_all as a building block for other things. For example, the current wording of let_async_scope (https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3296r1.html) uses when_all to ensure the async scope is joined, like this:

    auto result_sender = when_all(just_error(std::current_exception()), state.scope.join());

...the problem with this is that when the environment sent a cancellation request earlier, neither of the two senders will be called, not even the async scope's join sender, making this incorrect, I believe.

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