Skip to content

Using a join_sender in when_all is dangerous #41

Description

@jiixyj

In the current async_scope draft, when_all is sometimes used to join a scope together with some other senders, for example:

sender auto snd = spawn_future(on(sched, key_work()), scope) | then(continue_fun);
for (int i = 0; i < 10; i++)
    spawn(on(sched, other_work(i)), scope);
return when_all(scope.join(), std::move(snd));

...at the end of 5.6 of p3149r3.

However, if the whole work is cancelled, when_all will not even start the join_sender, but exit early with set_stopped.

The proposed finally may be a better option:

return finally(std::move(snd), scope.join());

Still, I wonder if it would be best for when_all to "just work" for this use case as well, see also cplusplus/sender-receiver#295 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions