Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: inc after work #522

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/finebars.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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