rust-lang / futures-rs

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

FuturesUnordered poll ordering guarantees #2674

Open david-monroe opened 1 year ago

david-monroe commented 1 year ago

The tokio-postgres crate executes queries in the order in which they are first polled. If two queries depend on each other, then their initial polling order must be the correct order. Subsequent polls are irrelevant. Currently FuturesUnordered polls futures pushed onto the queue initially in that order. Can we add this guarantee to the FuturesUnordered documentation?

taiki-e commented 1 year ago

I believe this is the behavior provided by the fact that the ReadyToRunQueue used inside the FuturesUnordered is a FIFO queue, but I would prefer not to document the exact behavior. (I think guarantees regarding "poll ordering" are very easily misunderstood and difficult to explain correctly.)

Instead, I would accept adding a test to check the behavior that you expect. If that test fails, we can treat it as a breaking change.