use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::thread;
use std::time::Duration;
use utls::{
prog::{PBStyle, Spinner, PB},
vars::framerate::SIXTY_FPS,
};
fn main() {
let value = Arc::new(AtomicUsize::new(0));
let pb = PB::builder(100)
.style(PBStyle::modern())
.width(100)
.formatting(false)
.message("{p}%")
.adv_stats(true)
.update_frequency(SIXTY_FPS)
.defer(false)
.precision(1)
.spinner(Some(Spinner::fancy()))
.build();
let (_handle, pb_arc) = pb.map(&value);
for _ in 0..100 {
value.fetch_add(1, Ordering::Relaxed);
thread::sleep(Duration::from_millis(50));
}
_handle.join().unwrap();
pb_arc
.lock()
.unwrap()
.finish_with_message("Success!");
let stats = pb_arc.lock().unwrap().get_stats();
println!("{}", stats);
}