Skip to content

Commit

Permalink
fix: inc after work
Browse files Browse the repository at this point in the history
  • Loading branch information
tatref authored and djc committed May 23, 2023
1 parent 59cd606 commit e0494e4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/finebars.rs
Expand Up @@ -28,9 +28,9 @@ fn main() {
let wait = Duration::from_millis(thread_rng().gen_range(10..30));
thread::spawn(move || {
for i in 0..512 {
thread::sleep(wait);
pb.inc(1);
pb.set_message(format!("{:3}%", 100 * i / 512));
thread::sleep(wait);
}
pb.finish_with_message("100%");
})
Expand Down
2 changes: 1 addition & 1 deletion examples/morebars.rs
Expand Up @@ -18,8 +18,8 @@ fn main() {
let pb2 = m.add(ProgressBar::new(128));
pb2.set_style(sty.clone());
for _ in 0..128 {
pb2.inc(1);
thread::sleep(Duration::from_millis(5));
pb2.inc(1);
}
pb2.finish();
pb.inc(1);
Expand Down
2 changes: 1 addition & 1 deletion examples/multi-tree.rs
Expand Up @@ -110,6 +110,7 @@ fn main() {
let mut rng = ThreadRng::default();
pb_main.tick();
loop {
thread::sleep(Duration::from_millis(15));
match get_action(&mut rng, &tree) {
None => {
// all elements were exhausted
Expand Down Expand Up @@ -137,7 +138,6 @@ fn main() {
pb_main.inc(1);
}
}
thread::sleep(Duration::from_millis(15));
}
})
.join();
Expand Down
6 changes: 3 additions & 3 deletions examples/multi.rs
Expand Up @@ -25,9 +25,9 @@ fn main() {
let m_clone = m.clone();
let h1 = thread::spawn(move || {
for i in 0..128 {
thread::sleep(Duration::from_millis(15));
pb.set_message(format!("item #{}", i + 1));
pb.inc(1);
thread::sleep(Duration::from_millis(15));
}
m_clone.println("pb1 is done!").unwrap();
pb.finish_with_message("done");
Expand All @@ -38,9 +38,9 @@ fn main() {
for _ in 0..3 {
pb2.set_position(0);
for i in 0..128 {
thread::sleep(Duration::from_millis(8));
pb2.set_message(format!("item #{}", i + 1));
pb2.inc(1);
thread::sleep(Duration::from_millis(8));
}
}
m_clone.println("pb2 is done!").unwrap();
Expand All @@ -50,9 +50,9 @@ fn main() {
let m_clone = m.clone();
let h3 = thread::spawn(move || {
for i in 0..1024 {
thread::sleep(Duration::from_millis(2));
pb3.set_message(format!("item #{}", i + 1));
pb3.inc(1);
thread::sleep(Duration::from_millis(2));
}
m_clone.println("pb3 is done!").unwrap();
pb3.finish_with_message("done");
Expand Down
2 changes: 1 addition & 1 deletion examples/single.rs
Expand Up @@ -6,8 +6,8 @@ use indicatif::ProgressBar;
fn main() {
let pb = ProgressBar::new(1024);
for _ in 0..1024 {
pb.inc(1);
thread::sleep(Duration::from_millis(5));
pb.inc(1);
}
pb.finish_with_message("done");
}
4 changes: 2 additions & 2 deletions examples/yarnish.rs
Expand Up @@ -58,8 +58,8 @@ pub fn main() {
let deps = 1232;
let pb = ProgressBar::new(deps);
for _ in 0..deps {
pb.inc(1);
thread::sleep(Duration::from_millis(3));
pb.inc(1);
}
pb.finish_and_clear();

Expand All @@ -80,9 +80,9 @@ pub fn main() {
let pkg = PACKAGES.choose(&mut rng).unwrap();
for _ in 0..count {
let cmd = COMMANDS.choose(&mut rng).unwrap();
thread::sleep(Duration::from_millis(rng.gen_range(25..200)));
pb.set_message(format!("{pkg}: {cmd}"));
pb.inc(1);
thread::sleep(Duration::from_millis(rng.gen_range(25..200)));
}
pb.finish_with_message("waiting...");
})
Expand Down

0 comments on commit e0494e4

Please sign in to comment.