yoshuawuyts / futures-concurrency

Structured concurrency operations for async Rust
https://docs.rs/futures-concurrency
Apache License 2.0
414 stars 33 forks source link

`Stream::merge` may be susceptible to stream "barbara battles buffered streams" #165

Open yoshuawuyts opened 9 months ago

yoshuawuyts commented 9 months ago

Tmandry's post showed how progressing a stream + concurrently executing a stream can lead to timeouts - this will affect Stream::merge as well. Probably the better solution is #164 which can run the processing concurrently with the underlying stream.

yoshuawuyts commented 9 months ago

(note that this isn't an issue if you ensure that the function bodies in Stream::merge are short-lived)

yoshuawuyts commented 8 months ago

What I'm concretely proposing here is: Stream::merge should return a new trait, ConcurrentStream which can concurrently progress both the underlying streams and the individually handled items. That's a change from today, where Stream::merge returns a regular Stream which if used incorrectly may lead to the issues mentioned.

yoshuawuyts commented 7 months ago

164 implements ConcurrentStream. We may want Stream::merge to return that instead. At the very least we should try and experiment with that.