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
Single-threaded MultiProgress #33
Comments
Ran into this issue directly today also when I tried out this crate. I had some single-threadedcode that has multiple progress bars that I want to be able to update but they didn't show up at all when using |
Yeah. I wanted to clean this up already. For now I'm accepting pull requests to make this better because I did not come up with a nice design for it. |
In the end I went ahead and published my own progress bar crate, yapb, which has a much simpler implementation and does not make assumptions about use patterns or even IO. |
Had this problem with futures today. Lots of stuff to progress, but only one thread. |
#231 and #234 may address this: the former makes ProgressBars in a MultiProgress update their shared draw target synchronously, the latter reworks batching / ratelimiting of terminal updates so it's fully shared by MultiProgress and single bars. After those two changes, MultiProgress no longer requires using a separate thread to run update(), and is entirely single-threaded when updates are not ratelimited (using (I still don't really like this design: seems like the draw targets should only receive notifications that state changed, not a full draw state, and the draw targets should then be able to request the bars to render themselves when they want to redraw. That'd mean less wasted work, and the possibility of doing something like steady_tick and redraws on terminal size changes in the draw target. That's more of a redesign than I'd like to tackle, though.) |
while not ideal, it does work if you can spin up a separate thread for the MultiProgress instance: let multi_progress = MultiProgress::new();
let progress_one = mp.add(ProgressBar::new_spinner());
let progress_two = mp.add(ProgressBar::new_spinner());
let progress_three = mp.add(ProgressBar::new_spinner());
let multi_progress = thread::spawn(move || multi_progress.join());
// do work
for i in 0..10 {
progress_one.inc(1);
progress_two.inc(1);
progress_three.inc(1);
}
progress_one.finish();
progress_two.finish();
progress_three.finish();
multi_progress.join().unwrap(); |
I'm going to close this. |
MultiProgress
seems to conflate support for displaying and update multiple progress bars concurrently and support for updating progress bars from multiple threads. It would be nice to isolate these so that a single thread performing multiple tasks can effectively useMultiProgress
. Inter-thread communication could perhaps even be left up to the user.The text was updated successfully, but these errors were encountered: