Skip to content
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

MultiProgress: prune 'zombie' progress bars; fixes #426; add render tests #438

Merged
merged 3 commits into from Jun 13, 2022

Conversation

chris-laplante
Copy link
Collaborator

No description provided.

@chris-laplante
Copy link
Collaborator Author

@djc FYI this draft PR so far just introduces a test that demonstrates issue #426. I am working on implementing the fix.

@chris-laplante chris-laplante force-pushed the cpl/prune-test branch 3 times, most recently from 9f7ca0c to 02112d0 Compare May 27, 2022 19:34
@chris-laplante chris-laplante changed the title Fixes for #426 and test that demonstrates the problem MultiProgress: prune 'zombie' progress bars; fixes #426; add render tests May 27, 2022
@chris-laplante chris-laplante marked this pull request as ready for review May 27, 2022 19:35
@chris-laplante chris-laplante requested a review from djc May 27, 2022 19:35
Copy link
Collaborator

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty sensible, commented on some possible improvements.

src/multi.rs Outdated Show resolved Hide resolved
src/multi.rs Outdated Show resolved Hide resolved
src/multi.rs Show resolved Hide resolved
src/multi.rs Outdated Show resolved Hide resolved
src/multi.rs Outdated
}

#[derive(Default)]
struct MultiStateElement {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So with draw_state: Option<_> and is_zombie: bool we have 4 different states. Do we need all 4? Maybe that would be a useful thing to explain in a comment?

I was surprised Weak implements Default -- it clearly works but it feels a little ugly to me. If we can collapse some of the states maybe there's something better we can do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, only three states are necessary:

  1. On MultiProgress::internalize (and before draw) draw_state will be None and is_zombie will be false.
  2. On draw, draw_state will be Some(..) and is_zombie will be false.
  3. When a zombie is detected, is_zombie will become true. Normally draw_state will be Some(..) but I suppose it's possible for a pb to be briefly in zombie state if it was never drawn (i.e. you immediately drop it after adding to the MultiProgress).

I'll add a comment to this effect.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One option would be to have an enum, but I think that would make the code even uglier.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By "suppose it's possible", I think you're suggesting that we actually do have 4 states?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there are technically four states. But state 3 and 4 (with 4 being "is_zombie == true" and "draw_state is None") are handled the same.

@chris-laplante
Copy link
Collaborator Author

OK, this should be a little better (hopefully)

@djc
Copy link
Collaborator

djc commented Jun 13, 2022

Would you mind squashing the review feedback commit back into the originating commit? Would make reviewing easier.

@chris-laplante
Copy link
Collaborator Author

OK, squashed. Sorry about that. I know I need to get better at structuring my commits :/

@djc djc merged commit af5d925 into console-rs:main Jun 13, 2022
@chris-laplante chris-laplante deleted the cpl/prune-test branch June 16, 2022 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants