I am making something like below! function1() and function2() both are doing async steps to insert a large amount of data into the database. However, I think join_all() can't handle too much data. It always stop after I inserted about 1500 data. I saw someone say FuturesUnordered is good to handle large operations, but I didn't find any example for it. Is anyone has experience with it? If so, can show to how to convert my code to use FuturesUnordered?
async fn main() {
println!("Start to insert data to database!");
block_on(hold());
}
async fn hold() {
let futures = vec![function1(),function2()];
let _results = future::join_all(futures).await;
}
Below, is the code I did for FuturesUnordered, but not work!
async fn main() {
println!("Start to insert data to database!");
block_on(hold());
}
async fn hold() {
let futures = FuturesUnordered::collect(function1(),function2());
let _results = FuturesUnordered::poll(futures).await;
}