use indicatif::{MultiProgress, ProgressBar};
use lending_thread_pool::ThreadPool;
use std::{thread::sleep, time::Duration};
pub fn main() {
let cores = 4;
let tasks = 16;
let multi_pb = MultiProgress::new();
let main_pb = multi_pb.add(ProgressBar::new(tasks));
let mut pool = ThreadPool::new(
(0..cores)
.map(|_| multi_pb.add(ProgressBar::new(10)))
.collect::<Vec<_>>(),
);
for _ in 0..tasks {
sleep(Duration::from_millis(100));
pool.enqueue(move |progress_bar| {
for _ in 0..10 {
sleep(Duration::from_millis(10));
progress_bar.inc(1);
}
progress_bar.reset();
});
main_pb.inc(1);
}
}