From 98478c664ef142cb2aee547b82aa5598d95c8659 Mon Sep 17 00:00:00 2001 From: Chris Laplante Date: Tue, 2 Aug 2022 16:35:56 -0400 Subject: [PATCH] demonstrate yarnish example modifications with zombie reaping --- examples/yarnish.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/yarnish.rs b/examples/yarnish.rs index 1cfdf70e..00f54ba7 100644 --- a/examples/yarnish.rs +++ b/examples/yarnish.rs @@ -69,12 +69,14 @@ pub fn main() { PAPER ); let m = MultiProgress::new(); + let mut to_clear = vec![]; let handles: Vec<_> = (0..4u32) .map(|i| { let count = rng.gen_range(30..80); let pb = m.add(ProgressBar::new(count)); pb.set_style(spinner_style.clone()); pb.set_prefix(format!("[{}/?]", i + 1)); + to_clear.push(pb.clone()); thread::spawn(move || { let mut rng = rand::thread_rng(); let pkg = PACKAGES.choose(&mut rng).unwrap(); @@ -91,7 +93,10 @@ pub fn main() { for h in handles { let _ = h.join(); } - m.clear().unwrap(); + + for pb in to_clear.drain(..) { + pb.finish_and_clear(); + } println!("{} Done in {}", SPARKLE, HumanDuration(started.elapsed())); }