tokio::task::spawn returns tokio::task::JoinHandle
pub async fn evaluate(self : Arc<Self>, par : Par) {
let evaluators : Vec<ThreadSafeEvaluator>;
evaluators = par.sends.into_iter().map( |s| s.into() )
.chain( par.receives.into_iter().map( |r| r.into() ) )
.collect();
let mut handles = Vec::new();
for (_idx, evaluator) in evaluators.into_iter().enumerate() {
let cloned_self = self.clone();
handles.push(
task::spawn( async move {
evaluator.evaluate(cloned_self).await;
})
);
}
}
If I can wait for all the tasks completion, I dont need wrap Self
with Arc
.
How can I await
(not blocking wait) all the handles
?
Full source code can be found here
Thanks in advance