From 4309099883135f37d8f71578406624d558921a35 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Tue, 25 Feb 2020 17:54:50 +0100 Subject: [PATCH] In control_flow example, don't schedule a new WaitUntil if wait was cancelled --- examples/control_flow.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/control_flow.rs b/examples/control_flow.rs index a76f9f4f53..13b5bcf832 100644 --- a/examples/control_flow.rs +++ b/examples/control_flow.rs @@ -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