In control_flow example, don't schedule a new WaitUntil if wait was cancelled (#1482)

This commit is contained in:
Philippe Renon 2020-03-06 18:48:54 +01:00 committed by GitHub
parent ece2e70a53
commit b8326f6452
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -100,7 +100,13 @@ fn main() {
Event::RedrawEventsCleared => {
*control_flow = match mode {
Mode::Wait => ControlFlow::Wait,
Mode::WaitUntil => ControlFlow::WaitUntil(time::Instant::now() + WAIT_TIME),
Mode::WaitUntil => {
if wait_cancelled {
*control_flow
} else {
ControlFlow::WaitUntil(time::Instant::now() + WAIT_TIME)
}
}
Mode::Poll => {
thread::sleep(POLL_SLEEP_TIME);
ControlFlow::Poll