Multi Progress

MultiProgress owns a single renderer and stores bars in draw order. Child bars are updated through their normal ProgressBar handles, and join refreshes the block until every bar is finished or abandoned.

Thread Safety

ProgressBar and MultiProgress use Arc<Mutex<_>> internally. Cloning either handle shares the same state, which makes them suitable for worker threads.

#![allow(unused)]
fn main() {
use loaders::{MultiProgress, ProgressBar};
use std::thread;

let multi = MultiProgress::new();
let pb = multi.add(ProgressBar::new(10));
let handle = thread::spawn(move || {
    for _ in 0..10 {
        pb.inc(1);
    }
    pb.finish();
});
multi.join();
let _ = handle.join();
}

Ordering

Use add to append, insert for an index, insert_before and insert_after for relative placement, and remove when a bar should leave the block.

Messages Above the Block

multi.println("message") prints without corrupting the progress area. It is useful for phase names, warnings, and completed file names.

Best Practices

Create the MultiProgress on the main thread, add bars before spawning workers, clone or move each returned ProgressBar into the worker, and call join from the thread that owns the terminal.