Function kdam::monitor::bar

source ·
pub fn bar(pb: Bar, maxinterval: f32) -> (Arc<Mutex<Bar>>, JoinHandle<()>)
Expand description

Monitor mode for Bar.

§Example

use kdam::{tqdm, BarExt};

let pb = tqdm!(total = 100, force_refresh = true);
let (pb_arc, monitor_thread) = kdam::monitor::bar(pb, 1.0);

for _ in 0..100 {
    pb_arc.lock().unwrap().update(1);
    std::thread::sleep(std::time::Duration::from_secs_f32(3.0));
}

monitor_thread.join().unwrap();
eprintln!();
Examples found in repository?
examples/miscellaneous/monitor_mode.rs (line 6)
4
5
6
7
8
9
10
11
12
13
14
15
16
fn main() -> Result<()> {
    let pb = tqdm!(total = 100, force_refresh = true);
    let (pb_arc, monitor_thread) = kdam::monitor::bar(pb, 1.0);

    for _ in 0..100 {
        pb_arc.lock().unwrap().update(1)?;
        std::thread::sleep(std::time::Duration::from_secs_f32(3.0));
    }

    monitor_thread.join().unwrap();
    eprintln!();
    Ok(())
}