Minor tokio cleanup

This commit is contained in:
Zhaofeng Li 2021-02-10 10:29:17 -08:00
parent 9f4d5a2221
commit afabd8c6f9
6 changed files with 23 additions and 69 deletions

View file

@ -139,7 +139,7 @@ pub async fn run(_global_args: &ArgMatches<'_>, local_args: &ArgMatches<'_>) {
let command = command.clone();
let progress = progress.clone();
futures.push(tokio::spawn(async move {
futures.push(async move {
let permit = match parallel_sp.as_ref() {
Some(sp) => Some(sp.acquire().await.unwrap()),
None => None,
@ -166,7 +166,7 @@ pub async fn run(_global_args: &ArgMatches<'_>, local_args: &ArgMatches<'_>) {
}
drop(permit);
}));
});
}
join_all(futures).await;

View file

@ -27,7 +27,7 @@ macro_rules! bind_command {
};
}
#[tokio::main(flavor = "multi_thread")]
#[tokio::main]
async fn main() {
init_logging();

View file

@ -274,8 +274,7 @@ impl Deployment {
let arc_self = self.clone();
let progress = progress.clone();
// how come the bars show up only when initialized here???
futures.push(tokio::spawn(async move {
futures.push(async move {
let permit = arc_self.parallelism_limit.apply.acquire().await.unwrap();
let mut process = progress.create_process_progress(node.clone());
@ -294,7 +293,7 @@ impl Deployment {
}
drop(permit);
}));
});
}
join_all(futures).await
@ -334,7 +333,7 @@ impl Deployment {
// FIXME: Eww
let chunk: Vec<String> = chunk.iter().map(|s| s.to_string()).collect();
futures.push(tokio::spawn(async move {
futures.push(async move {
let drv = {
// Evaluation phase
let permit = arc_self.parallelism_limit.evaluation.acquire().await.unwrap();
@ -401,12 +400,12 @@ impl Deployment {
let profile = profiles.get(&node).cloned()
.expect(&format!("Somehow profile for {} was not built", node));
futures.push(tokio::spawn(async move {
futures.push(async move {
arc_self.apply_profile(&node, target, profile, progress).await
}));
});
}
}));
join_all(futures).await;
});
}
join_all(futures).await;