Add join_all function for waiting on an iterator of futures
- Dominant language
- Rust
- Stars
- 4.1k
- Forks
- 339
- PR merge metrics
- No merged PRs in 30d
Description
Hi, everyone. Thank you for reading this issue. The crate futures has a function [futures::future::join_all](https://docs.rs/futures/0.3.12/futures/future/fn.join_all.html). But the performance of this function in futures seem not very good. [Tokio has talked about this](https://github.com/tokio-rs/tokio/issues/2401#issuecomment-612858572).
Will async_std provide this function? I'm willing to work on this. If I add a vec marks in JoinAll to record ready futures to prevent poll them again, can solve this performance problem?
```rust
//struct JoinAll looks like this
pin_project! {
#[allow(missing_docs)]
#[allow(missing_debug_implementations)]
pub struct JoinAll
where
F: Future,
{
#[pin] elems: Box<[MaybeDone]>,
#[pin] marks: Box>,
}
}
// test
async_std::task::block_on(async {
use async_std::prelude::*;
use async_std::future;
let futurevec = vec![future::ready(5u8), future::ready(6u8)];
let join_all = future::ready(0).join_all(futurevec);
let result = join_all.await;
let mut count = 0;
for i in result.iter() {
println!("test count:{},result:{}", count, i);
count += 1;
}
assert_eq!(result, [5u8, 6u8]);
});
``````
Contributor guide
Assessment
This issue has not been assessed yet.