cplusplus / sender-receiver

Issues list for P2300
Apache License 2.0
19 stars 3 forks source link

`split` sender's cancellation behavior is unexpected #200

Closed ericniebler closed 3 months ago

ericniebler commented 7 months ago

Cancelling any of the split senders causes the underlying operation to be cancelled. It should probably only be cancelled if all the split senders are cancelled.

lewissbaker commented 7 months ago

The reason why the split() semantics are the way it is to prevent the case where:

This is exactly the same scenario as ensure_started() and has the same lifetime footguns.

If we want split to have the behaviour of only cancelling when the last consumer cancels then it needs to be tied to some form of scope. This could either be an async-scope, with a spawn_shared() function. Or it could be a structured algorithm such as let_concurrent_shared(s, [](auto copyable_s) { ... }).

lewissbaker commented 3 months ago

I have created #263 to track creating a better split() algorithm.

lewissbaker commented 3 months ago

Closing as duplicate to consolidate work into #263.