-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: MultiProgress insert_from_back #326
Conversation
It may not matter that much, but wouldn't that be subject to a race condition if another thread added a new progress bar between the call to An alternative would be I run into this when I have an overall status bar at the bottom, and then add subactions above, when there are enough subactions (or a more are added as we go) that the overall status bar would scroll offscreen. |
I think just using insert without relying on the length of the use indicatif::{MultiProgress, ProgressBar};
use std::{sync::Arc, thread};
fn main() {
let mp = Arc::new(MultiProgress::new());
let first_bar = ProgressBar::new(100);
let second_bar = ProgressBar::new(100);
let mp_1 = Arc::clone(&mp);
let thread_1 = thread::spawn(move || {
mp_1.insert(0, first_bar);
});
let mp_2 = Arc::clone(&mp);
let thread_2 = thread::spawn(move || {
mp_2.insert(0, second_bar);
});
thread_1.join().unwrap();
thread_2.join().unwrap();
// bars in mp have unknown order
} A potential way this could be mitigated would be to change |
I'd prefer an |
@djc I have changed this PR to add an |
Thanks! |
Add
insert_from_back
method toMultiProgress