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
[RFC] Remove MultiProgress::join() #231
Conversation
Instead of drawing from a thread blocked on MultiProgress::join(), draw directly from the threads updating the ProgressBars in the MultiProgress, using write access to MultiProgress's state to synchronize terminal updates.
My main question on this direction is whether it creates new problems for scoping of the MultiProgress and threads. I don't know that it does, but also don't currently know that it doesn't. |
I'm not sure if I understand the question about scoping. Can you give an example you're concerned about? To port to the new code, all you should have to do is remove the call to |
We set this from the "finished" field of a ProgressDrawState, which we also store. It does not look like the separate field is necessary.
#234 adds the promised DrawTarget-with-a-timer. |
This branch solved a problem I was having with my application structure. Thanks for the work! |
Sorry for taking so long to get to this. I do think this idea makes sense. Would you be willing to rebase it on top of current main? It looks like some of the structural changes that you made are already part of main now, but there have been quite a few changes, so the rebase might be a little painful. |
I like this too, I have rebased @marienz's changes onto main and added a leaky bucket to the rate limiting to fix the regression on #166 in aj-bagwell:multiprogress-unjoined if that helps keep this moving. |
Sounds great, would you mind submitting a separate PR for this? |
Okay, I'll close this for now. |
This should not be merged yet, but I'd like to know if this looks like something worth pursuing.
This change moves drawing of MultiProgress from the join() thread to the child ProgressBar updates.
This has the following advantages:
unsafe
in indicatif: MultiProgress is now automaticallySync
).It also has disadvantages, most of which I think can be mitigated:
rate - last_draw.elapsed()
in the future if we don't want to draw immediately. I haven't written the code for this yet, though, so it might not be as easy as I think...ProgressDrawTargetKind
, which is fine as those are not public) if the old behavior is deemed useful enough to keep around and/or we want to avoid the semver bump.I think the DrawTarget-with-a-timer is useful anyway: it should mitigate a problem very similar to #166 when doing something like:
This currently only shows "you should not see this" for the same reason the MultiProgress example didn't stay in sync. With a DrawTarget-with-a-timer, it would show "you should not see this" for only one update interval. So I'll probably see if I can get that to work even if this change isn't deemed useful.
Please let me know what you think!