rust-lang / futures-rs

Zero-cost asynchronous programming in Rust
https://rust-lang.github.io/futures-rs/
Apache License 2.0
5.34k stars 616 forks source link

Retain method for SelectAll streams #2753

Open TylerBloom opened 1 year ago

TylerBloom commented 1 year ago

Currently, there is no ergonomic way to manage the internal streams in a SelectAll. In particular, there is no way to remove streams with a significant workaround. It would be nice to have a method such as retain that could be used to remove streams that are owned by the SelectAll. This would be particularly helpful for long-running SelectAll streams whose constituent streams live for much less time.

taiki-e commented 1 year ago

At first glance, this seems reasonable to me.

TylerBloom commented 11 months ago

I was recently revisiting this idea. While the retain method that I proposed could (and maybe should) be implemented, a better solution to the problem that I described is a SelectAll for FusedStreams. This would function similarly to the SelectAll futures in that a stream is dropped as soon as it knows that it is finished.