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

Write output from a background thread #8

Open
sourcefrog opened this issue Oct 19, 2022 · 0 comments
Open

Write output from a background thread #8

sourcefrog opened this issue Oct 19, 2022 · 0 comments

Comments

@sourcefrog
Copy link
Owner

Currently, every call to View::update updates the model and then may, or may not, write output to stdout (or wherever) depending on rate limiting.

It might be good to instead have a thread dedicated to pushing updates:

  1. The application thread that provided the update can return to its own real work faster, without potentially blocking writing to a slow terminal. (However, since updates are rate-limited, these writes should happen rarely and might not have much of an effect? Or they might?)
  2. If a progress bar update happens within the cooldown from the last update, it has missed its chance to be painted: the progress bar will not repaint until there's another model update. Similarly, after a message is written the progress bar will not repaint until there's a new model update. This isn't a problem for applications that issue many updates, but for those that update sporadically it can be strange: the bar doesn't show the thing that's actually causing a long pause. Asynchronous repainting would let the bar paint every n milliseconds with whatever is the most current state.

I'm not sure if messages should also be painted by an asynchronous thread, presumably with some queue in between.

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

No branches or pull requests

1 participant