-
Notifications
You must be signed in to change notification settings - Fork 947
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
Make ControlFlow::Wait
the default
#3106
Make ControlFlow::Wait
the default
#3106
Conversation
39b80f0
to
40e2f9c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue we should consider is that initial iteration, should still be with Poll
, however anything further is with the default behavior. The reason behind is that you technically have events, and the event is the StartCause
, but with Wait
you'll wait for the actual events coming from the user or the windowing system, which might not be desirable for the first iteration.
What we should do, is to just switch the user default, but we shouldn't change the way kick start of the loop works, since we always have an event (StartCause::Init
) and we simply need a wakeup, which Wait
internally in the backends might not deliver it.
I'd also suggest to emphasize on the Poll
internally, for the first loop iteration, like it's done in Wayland/X11, so you have more predictable startup, which should be fine across the backends.
@@ -230,7 +230,7 @@ impl<T: 'static> EventLoop<T> { | |||
// Reset the internal state for the loop as we start running to | |||
// ensure consistent behaviour in case the loop runs and exits more | |||
// than once. | |||
self.set_control_flow(ControlFlow::Poll); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can keep the Poll
here, I think motivation is to do the first loop iteration non-blocking, because if you see the code, it won't get reset anymore? We just need to change the user default, but if the code really hardcodes the poll it's likely only a one time action.
I'm not following. If |
@daxpedda yes, that's what I'm saying that they could go to sleep in such cases for the first iteration, because the event by its nature, is synthetic, so it can act like it won't wake up the event loop. I think Wayland/X11 backends will need more tuning than what you've done, but there's no issue to keeping the In practice, this won't change anything for the end users, since the default polling is still |
40e2f9c
to
684f617
Compare
I assume I still have to put it back to |
Maybe it's not clear what I suggested, but I'll clarify:
What you confuse is the policy with the behavior, users are setting the polling policy, how the backend follows that policy is up to the backend. It could use different polling internally, but it should look like the |
So, how the change should look is that you simply change the default on the |
684f617
to
241c619
Compare
After some IRC conversations we figured out that this was already an issue before this PR. |
After some discussion in #3105 I was asking myself why
Poll
is the default. So I wanted to know what everybody thinks about switching the default toWait
.I will make a follow-up to try and improve the documentation around our recommendations on which
ControlFlow
to choose, but wanted to keep it separate.