Struct kdam::RowManager

source ·
pub struct RowManager { /* private fields */ }
Expand description

RowManager allows to store and update many progress bars.

nrows is the number of progress bars to display at once. All other bars are hidden and visible once any active progress bar is completed. Traces of progress are left in terminal if leave is true else progress bar is cleared.

Note

Cursor positions are not restored by RowManager.

Example

use kdam::{tqdm, BarExt, RowManager};

let mut manager = RowManager::new(3);
let pb_index = manager.push(tqdm!(total = 100)).unwrap();

for _ in 0..100 {
    manager.get_mut(pb_index).unwrap().update(1).unwrap();
    manager.notify(pb_index).unwrap();
}

manager.remove(pb_index);

Implementations§

source§

impl RowManager

source

pub fn new(nrows: u16) -> Self

Create a new RowManager with specified number of rows.

Example
use kdam::RowManager;

// Display 3 progress bars at once.
let manager = RowManager::new(3);
Examples found in repository?
examples/multiple/row_manager_keep.rs (line 13)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
fn main() -> Result<()> {
    term::init(false);
    term::hide_cursor()?;

    let mut manager = RowManager::new(3);

    for (i, total) in [150, 100, 200, 400, 500, 600].iter().enumerate() {
        manager.push(tqdm!(
            total = *total,
            desc = format!("BAR {}", i),
            force_refresh = true
        ))?;
    }

    let manager = Arc::new(Mutex::new(manager));

    let manager1 = manager.clone();
    let thread1 = thread::spawn(move || {
        for _ in 0..150 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager1.lock().unwrap();
            manager.get_mut(0).unwrap().update(1).unwrap();
            manager.notify(0).unwrap();
        }
    });

    let manager2 = manager.clone();
    let thread2 = thread::spawn(move || {
        for _ in 0..100 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager2.lock().unwrap();
            manager.get_mut(1).unwrap().update(1).unwrap();
            manager.notify(1).unwrap();
        }
    });

    let manager3 = manager.clone();
    let thread3 = thread::spawn(move || {
        for _ in 0..200 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager3.lock().unwrap();
            manager.get_mut(2).unwrap().update(1).unwrap();
            manager.notify(2).unwrap();
        }
    });

    let manager4 = manager.clone();
    let thread4 = thread::spawn(move || {
        for _ in 0..400 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager4.lock().unwrap();
            manager.get_mut(3).unwrap().update(1).unwrap();
            manager.notify(3).unwrap();
        }
    });

    let manager5 = manager.clone();
    let thread5 = thread::spawn(move || {
        for _ in 0..500 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager5.lock().unwrap();
            manager.get_mut(4).unwrap().update(1).unwrap();
            manager.notify(4).unwrap();
        }
    });

    let manager6 = manager;
    let thread6 = thread::spawn(move || {
        for _ in 0..600 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager6.lock().unwrap();
            manager.get_mut(5).unwrap().update(1).unwrap();
            manager.notify(5).unwrap();
        }
    });

    for thread in [thread1, thread2, thread3, thread4, thread5, thread6] {
        thread.join().unwrap();
    }

    println!("\rcompleted!");
    Ok(())
}
More examples
Hide additional examples
examples/multiple/row_manager_clean.rs (line 13)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
fn main() -> Result<()> {
    term::init(false);
    term::hide_cursor()?;

    let mut manager = RowManager::new(3);

    for (i, total) in [150, 100, 200, 400, 500, 600].iter().enumerate() {
        manager.push(tqdm!(
            total = *total,
            leave = false,
            desc = format!("BAR {}", i),
            force_refresh = true
        ))?;
    }

    let manager = Arc::new(Mutex::new(manager));

    let manager1 = manager.clone();
    let thread1 = thread::spawn(move || {
        for _ in 0..150 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager1.lock().unwrap();
            manager.get_mut(0).unwrap().update(1).unwrap();
            manager.notify(0).unwrap();
        }
    });

    let manager2 = manager.clone();
    let thread2 = thread::spawn(move || {
        for _ in 0..100 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager2.lock().unwrap();
            manager.get_mut(1).unwrap().update(1).unwrap();
            manager.notify(1).unwrap();
        }
    });

    let manager3 = manager.clone();
    let thread3 = thread::spawn(move || {
        for _ in 0..200 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager3.lock().unwrap();
            manager.get_mut(2).unwrap().update(1).unwrap();
            manager.notify(2).unwrap();
        }
    });

    let manager4 = manager.clone();
    let thread4 = thread::spawn(move || {
        for _ in 0..400 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager4.lock().unwrap();
            manager.get_mut(3).unwrap().update(1).unwrap();
            manager.notify(3).unwrap();
        }
    });

    let manager5 = manager.clone();
    let thread5 = thread::spawn(move || {
        for _ in 0..500 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager5.lock().unwrap();
            manager.get_mut(4).unwrap().update(1).unwrap();
            manager.notify(4).unwrap();
        }
    });

    let manager6 = manager;
    let thread6 = thread::spawn(move || {
        for _ in 0..600 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager6.lock().unwrap();
            manager.get_mut(5).unwrap().update(1).unwrap();
            manager.notify(5).unwrap();
        }
    });

    for thread in [thread1, thread2, thread3, thread4, thread5, thread6] {
        thread.join().unwrap();
    }

    println!("\rcompleted!");
    Ok(())
}
source

pub fn from_window_size() -> Self

Create a new RowManager from terminal window size.

Example
use kdam::RowManager;

let mut manager = RowManager::from_window_size();
source

pub fn push(&mut self, pb: Bar) -> Result<usize>

Push a progress bar returning back it’s index.

Examples found in repository?
examples/multiple/row_manager_keep.rs (lines 16-20)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
fn main() -> Result<()> {
    term::init(false);
    term::hide_cursor()?;

    let mut manager = RowManager::new(3);

    for (i, total) in [150, 100, 200, 400, 500, 600].iter().enumerate() {
        manager.push(tqdm!(
            total = *total,
            desc = format!("BAR {}", i),
            force_refresh = true
        ))?;
    }

    let manager = Arc::new(Mutex::new(manager));

    let manager1 = manager.clone();
    let thread1 = thread::spawn(move || {
        for _ in 0..150 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager1.lock().unwrap();
            manager.get_mut(0).unwrap().update(1).unwrap();
            manager.notify(0).unwrap();
        }
    });

    let manager2 = manager.clone();
    let thread2 = thread::spawn(move || {
        for _ in 0..100 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager2.lock().unwrap();
            manager.get_mut(1).unwrap().update(1).unwrap();
            manager.notify(1).unwrap();
        }
    });

    let manager3 = manager.clone();
    let thread3 = thread::spawn(move || {
        for _ in 0..200 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager3.lock().unwrap();
            manager.get_mut(2).unwrap().update(1).unwrap();
            manager.notify(2).unwrap();
        }
    });

    let manager4 = manager.clone();
    let thread4 = thread::spawn(move || {
        for _ in 0..400 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager4.lock().unwrap();
            manager.get_mut(3).unwrap().update(1).unwrap();
            manager.notify(3).unwrap();
        }
    });

    let manager5 = manager.clone();
    let thread5 = thread::spawn(move || {
        for _ in 0..500 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager5.lock().unwrap();
            manager.get_mut(4).unwrap().update(1).unwrap();
            manager.notify(4).unwrap();
        }
    });

    let manager6 = manager;
    let thread6 = thread::spawn(move || {
        for _ in 0..600 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager6.lock().unwrap();
            manager.get_mut(5).unwrap().update(1).unwrap();
            manager.notify(5).unwrap();
        }
    });

    for thread in [thread1, thread2, thread3, thread4, thread5, thread6] {
        thread.join().unwrap();
    }

    println!("\rcompleted!");
    Ok(())
}
More examples
Hide additional examples
examples/multiple/row_manager_clean.rs (lines 16-21)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
fn main() -> Result<()> {
    term::init(false);
    term::hide_cursor()?;

    let mut manager = RowManager::new(3);

    for (i, total) in [150, 100, 200, 400, 500, 600].iter().enumerate() {
        manager.push(tqdm!(
            total = *total,
            leave = false,
            desc = format!("BAR {}", i),
            force_refresh = true
        ))?;
    }

    let manager = Arc::new(Mutex::new(manager));

    let manager1 = manager.clone();
    let thread1 = thread::spawn(move || {
        for _ in 0..150 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager1.lock().unwrap();
            manager.get_mut(0).unwrap().update(1).unwrap();
            manager.notify(0).unwrap();
        }
    });

    let manager2 = manager.clone();
    let thread2 = thread::spawn(move || {
        for _ in 0..100 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager2.lock().unwrap();
            manager.get_mut(1).unwrap().update(1).unwrap();
            manager.notify(1).unwrap();
        }
    });

    let manager3 = manager.clone();
    let thread3 = thread::spawn(move || {
        for _ in 0..200 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager3.lock().unwrap();
            manager.get_mut(2).unwrap().update(1).unwrap();
            manager.notify(2).unwrap();
        }
    });

    let manager4 = manager.clone();
    let thread4 = thread::spawn(move || {
        for _ in 0..400 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager4.lock().unwrap();
            manager.get_mut(3).unwrap().update(1).unwrap();
            manager.notify(3).unwrap();
        }
    });

    let manager5 = manager.clone();
    let thread5 = thread::spawn(move || {
        for _ in 0..500 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager5.lock().unwrap();
            manager.get_mut(4).unwrap().update(1).unwrap();
            manager.notify(4).unwrap();
        }
    });

    let manager6 = manager;
    let thread6 = thread::spawn(move || {
        for _ in 0..600 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager6.lock().unwrap();
            manager.get_mut(5).unwrap().update(1).unwrap();
            manager.notify(5).unwrap();
        }
    });

    for thread in [thread1, thread2, thread3, thread4, thread5, thread6] {
        thread.join().unwrap();
    }

    println!("\rcompleted!");
    Ok(())
}
source

pub fn get_mut(&mut self, index: usize) -> Option<&mut Bar>

Returns a mutable reference to progress bar.

Examples found in repository?
examples/multiple/row_manager_keep.rs (line 30)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
fn main() -> Result<()> {
    term::init(false);
    term::hide_cursor()?;

    let mut manager = RowManager::new(3);

    for (i, total) in [150, 100, 200, 400, 500, 600].iter().enumerate() {
        manager.push(tqdm!(
            total = *total,
            desc = format!("BAR {}", i),
            force_refresh = true
        ))?;
    }

    let manager = Arc::new(Mutex::new(manager));

    let manager1 = manager.clone();
    let thread1 = thread::spawn(move || {
        for _ in 0..150 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager1.lock().unwrap();
            manager.get_mut(0).unwrap().update(1).unwrap();
            manager.notify(0).unwrap();
        }
    });

    let manager2 = manager.clone();
    let thread2 = thread::spawn(move || {
        for _ in 0..100 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager2.lock().unwrap();
            manager.get_mut(1).unwrap().update(1).unwrap();
            manager.notify(1).unwrap();
        }
    });

    let manager3 = manager.clone();
    let thread3 = thread::spawn(move || {
        for _ in 0..200 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager3.lock().unwrap();
            manager.get_mut(2).unwrap().update(1).unwrap();
            manager.notify(2).unwrap();
        }
    });

    let manager4 = manager.clone();
    let thread4 = thread::spawn(move || {
        for _ in 0..400 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager4.lock().unwrap();
            manager.get_mut(3).unwrap().update(1).unwrap();
            manager.notify(3).unwrap();
        }
    });

    let manager5 = manager.clone();
    let thread5 = thread::spawn(move || {
        for _ in 0..500 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager5.lock().unwrap();
            manager.get_mut(4).unwrap().update(1).unwrap();
            manager.notify(4).unwrap();
        }
    });

    let manager6 = manager;
    let thread6 = thread::spawn(move || {
        for _ in 0..600 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager6.lock().unwrap();
            manager.get_mut(5).unwrap().update(1).unwrap();
            manager.notify(5).unwrap();
        }
    });

    for thread in [thread1, thread2, thread3, thread4, thread5, thread6] {
        thread.join().unwrap();
    }

    println!("\rcompleted!");
    Ok(())
}
More examples
Hide additional examples
examples/multiple/row_manager_clean.rs (line 31)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
fn main() -> Result<()> {
    term::init(false);
    term::hide_cursor()?;

    let mut manager = RowManager::new(3);

    for (i, total) in [150, 100, 200, 400, 500, 600].iter().enumerate() {
        manager.push(tqdm!(
            total = *total,
            leave = false,
            desc = format!("BAR {}", i),
            force_refresh = true
        ))?;
    }

    let manager = Arc::new(Mutex::new(manager));

    let manager1 = manager.clone();
    let thread1 = thread::spawn(move || {
        for _ in 0..150 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager1.lock().unwrap();
            manager.get_mut(0).unwrap().update(1).unwrap();
            manager.notify(0).unwrap();
        }
    });

    let manager2 = manager.clone();
    let thread2 = thread::spawn(move || {
        for _ in 0..100 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager2.lock().unwrap();
            manager.get_mut(1).unwrap().update(1).unwrap();
            manager.notify(1).unwrap();
        }
    });

    let manager3 = manager.clone();
    let thread3 = thread::spawn(move || {
        for _ in 0..200 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager3.lock().unwrap();
            manager.get_mut(2).unwrap().update(1).unwrap();
            manager.notify(2).unwrap();
        }
    });

    let manager4 = manager.clone();
    let thread4 = thread::spawn(move || {
        for _ in 0..400 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager4.lock().unwrap();
            manager.get_mut(3).unwrap().update(1).unwrap();
            manager.notify(3).unwrap();
        }
    });

    let manager5 = manager.clone();
    let thread5 = thread::spawn(move || {
        for _ in 0..500 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager5.lock().unwrap();
            manager.get_mut(4).unwrap().update(1).unwrap();
            manager.notify(4).unwrap();
        }
    });

    let manager6 = manager;
    let thread6 = thread::spawn(move || {
        for _ in 0..600 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager6.lock().unwrap();
            manager.get_mut(5).unwrap().update(1).unwrap();
            manager.notify(5).unwrap();
        }
    });

    for thread in [thread1, thread2, thread3, thread4, thread5, thread6] {
        thread.join().unwrap();
    }

    println!("\rcompleted!");
    Ok(())
}
source

pub fn notify(&mut self, index: usize) -> Result<()>

Update and print the required stuff for progress bar at that index.

Panics

If index is out of bounds.

Examples found in repository?
examples/multiple/row_manager_keep.rs (line 31)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
fn main() -> Result<()> {
    term::init(false);
    term::hide_cursor()?;

    let mut manager = RowManager::new(3);

    for (i, total) in [150, 100, 200, 400, 500, 600].iter().enumerate() {
        manager.push(tqdm!(
            total = *total,
            desc = format!("BAR {}", i),
            force_refresh = true
        ))?;
    }

    let manager = Arc::new(Mutex::new(manager));

    let manager1 = manager.clone();
    let thread1 = thread::spawn(move || {
        for _ in 0..150 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager1.lock().unwrap();
            manager.get_mut(0).unwrap().update(1).unwrap();
            manager.notify(0).unwrap();
        }
    });

    let manager2 = manager.clone();
    let thread2 = thread::spawn(move || {
        for _ in 0..100 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager2.lock().unwrap();
            manager.get_mut(1).unwrap().update(1).unwrap();
            manager.notify(1).unwrap();
        }
    });

    let manager3 = manager.clone();
    let thread3 = thread::spawn(move || {
        for _ in 0..200 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager3.lock().unwrap();
            manager.get_mut(2).unwrap().update(1).unwrap();
            manager.notify(2).unwrap();
        }
    });

    let manager4 = manager.clone();
    let thread4 = thread::spawn(move || {
        for _ in 0..400 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager4.lock().unwrap();
            manager.get_mut(3).unwrap().update(1).unwrap();
            manager.notify(3).unwrap();
        }
    });

    let manager5 = manager.clone();
    let thread5 = thread::spawn(move || {
        for _ in 0..500 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager5.lock().unwrap();
            manager.get_mut(4).unwrap().update(1).unwrap();
            manager.notify(4).unwrap();
        }
    });

    let manager6 = manager;
    let thread6 = thread::spawn(move || {
        for _ in 0..600 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager6.lock().unwrap();
            manager.get_mut(5).unwrap().update(1).unwrap();
            manager.notify(5).unwrap();
        }
    });

    for thread in [thread1, thread2, thread3, thread4, thread5, thread6] {
        thread.join().unwrap();
    }

    println!("\rcompleted!");
    Ok(())
}
More examples
Hide additional examples
examples/multiple/row_manager_clean.rs (line 32)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
fn main() -> Result<()> {
    term::init(false);
    term::hide_cursor()?;

    let mut manager = RowManager::new(3);

    for (i, total) in [150, 100, 200, 400, 500, 600].iter().enumerate() {
        manager.push(tqdm!(
            total = *total,
            leave = false,
            desc = format!("BAR {}", i),
            force_refresh = true
        ))?;
    }

    let manager = Arc::new(Mutex::new(manager));

    let manager1 = manager.clone();
    let thread1 = thread::spawn(move || {
        for _ in 0..150 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager1.lock().unwrap();
            manager.get_mut(0).unwrap().update(1).unwrap();
            manager.notify(0).unwrap();
        }
    });

    let manager2 = manager.clone();
    let thread2 = thread::spawn(move || {
        for _ in 0..100 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager2.lock().unwrap();
            manager.get_mut(1).unwrap().update(1).unwrap();
            manager.notify(1).unwrap();
        }
    });

    let manager3 = manager.clone();
    let thread3 = thread::spawn(move || {
        for _ in 0..200 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager3.lock().unwrap();
            manager.get_mut(2).unwrap().update(1).unwrap();
            manager.notify(2).unwrap();
        }
    });

    let manager4 = manager.clone();
    let thread4 = thread::spawn(move || {
        for _ in 0..400 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager4.lock().unwrap();
            manager.get_mut(3).unwrap().update(1).unwrap();
            manager.notify(3).unwrap();
        }
    });

    let manager5 = manager.clone();
    let thread5 = thread::spawn(move || {
        for _ in 0..500 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager5.lock().unwrap();
            manager.get_mut(4).unwrap().update(1).unwrap();
            manager.notify(4).unwrap();
        }
    });

    let manager6 = manager;
    let thread6 = thread::spawn(move || {
        for _ in 0..600 {
            thread::sleep(Duration::from_secs_f32(0.02));
            let mut manager = manager6.lock().unwrap();
            manager.get_mut(5).unwrap().update(1).unwrap();
            manager.notify(5).unwrap();
        }
    });

    for thread in [thread1, thread2, thread3, thread4, thread5, thread6] {
        thread.join().unwrap();
    }

    println!("\rcompleted!");
    Ok(())
}
source

pub fn remove(&mut self, index: usize) -> Bar

Removes a progress bar and returns it.

Panics

If index is out of bounds.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Ungil for Twhere T: Send,