Execute vector of futures in parallel with the supplied number of threads

Viewed 669

I'm new to Rust and have the following issue.

I have a vector of std::Future and due to some weird requirements I have to create a new thread pool every time the futures are executed. Like the following:

fn execute_in_parallel(futs: Vec<Pin<Box<dyn Future<Output = Result<(), SomeError>> + Send>>>, threads_nums: u32) -> Vec<Result<(), SomeError>>{
    //create threads_nums threads and execute all the futures with them
}

I tried futures crate and its join_all function, but it does not seem to create any threads any time it is called.

Is there a way to do it? Maybe tokio would be helpful here.

0 Answers
Related