futures has a function called
join_all which is the most obvious choice in the situation: "I have a bunch of Futures and I want to collect and then do something with all their results once they're all done."
I ran into a curious situation building an experimental HTTP benchmarking tool using Tokio. Rather simple code here: https://github.com/fpgaminer/http-dyno/blob/45b4e59ac066709d2f8880195086ed30943bb1b5/src/main.rs
The gist of it is that I have a bunch of futures hammering a server with requests for some period of time. After they're all done I want to collect up and analyze stats from them to report back to the user.
join_all being the obvious choice here, it was my first thought. However using it would have shoved all those Futures into a single Task, killing performance. (IIUC a Task can only execute on a single thread at any given moment)
Luckily in my scenario there's a simple, performant solution (
Arc<Mutex<Vec<_>>>). But it got me wondering if Tokio has a more general solution.
join_all but where all the sub-futures become their own Tasks.
Obviously this can be implemented manually, but just wondering if Tokio or Futures has something built-in?