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

Add waiting for events to core #1112

Closed
bvssvni opened this issue Sep 1, 2016 · 4 comments
Closed

Add waiting for events to core #1112

bvssvni opened this issue Sep 1, 2016 · 4 comments
Labels

Comments

@bvssvni
Copy link
Member

bvssvni commented Sep 1, 2016

See discussion #1109

This could be very simple, such as adding Window::wait_event https://github.com/PistonDevelopers/glutin_window/blob/master/src/lib.rs#L125

@bvssvni
Copy link
Member Author

bvssvni commented Sep 21, 2016

This could also be added to the default event loop as a setting.

@christolliday
Copy link
Contributor

I looked into adding this to the various backends after adding it to just glutin_window, and I think the API I added there can be improved after looking at the other backends.

I previously added this method to GlutinWindow

fn wait_event(&mut self) -> Option<Self::Event>

but looking at the other backends, sdl2 and glfw, I think the best API is to have:

fn wait_event(&mut self) -> Self::Event
/// wait for an event, or for timeout to be reached
fn wait_event_timeout(&mut self, timeout: Duration) -> Option<Self::Event>`

The reasons are

  • wait_event can wait for as long as it takes to get an event, so there is need to return an option.
  • wait_event_timeout is especially useful for implementing a waiting loop that can still update at a fixed rate.
  • of glutin, glfw, and sdl2, only glutin has a straightforward way I could see to implement wait_event_timeout without a dedicated method, and that's by waking it up from another thread via a WindowProxy. Both SDL2 and glfw provides an equivalent method to wait_event_timeout so that should be exposed.

@christolliday
Copy link
Contributor

the glfw backend requires an extra method to be exposed via glfw-rs, so I made a pull request there PistonDevelopers/glfw-rs#358

If that and the piston changes get merged I can implement the new methods for all the various backends.

@bvssvni
Copy link
Member Author

bvssvni commented Oct 12, 2016

Closed by #1123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants