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

poll_events()/wait_events() are not enough for power efficient GUI apps #855

Closed
pedrocr opened this issue Jan 28, 2017 · 3 comments
Closed

Comments

@pedrocr
Copy link
Contributor

pedrocr commented Jan 28, 2017

The current events API is not enough to be able to have a GUI app that can both sit idle for minutes/hours when there are no new events as well as reacts to outside events not from the GUI. With the two current APIs you can:

  • poll_events(): Run a 60fps loop by first polling for events, then checking for outside events, then sleeping for 16ms. This gives you the correct behavior but has 60 wakeups per second which costs a bit of power.
  • wait_events(): Since it blocks the power issue is solved but there is then no way to react to other events.

The ideal API would be a form of wait_events() with a way to inject an artificial event from another thread so that it can be unblocked on demand. Maybe there's already a way of doing this?

@pedrocr
Copy link
Contributor Author

pedrocr commented Jan 28, 2017

Btw I came across this limitation while working on a conrod app event loop:

PistonDevelopers/conrod#915

@jwilm
Copy link
Contributor

jwilm commented Jan 28, 2017

@pedrocr You can get a WindowProxy which has a wakeup_event_loop() method. Looks like event iterators are going go away soon anyway.

@pedrocr
Copy link
Contributor Author

pedrocr commented Jan 28, 2017

@jwilm thanks, this does indeed work fine and makes for very simple code.

@pedrocr pedrocr closed this as completed Jan 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants