From b8326f6452550908fd79b76084450a688b0cc41e Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Fri, 6 Mar 2020 18:48:54 +0100 Subject: [PATCH] In control_flow example, don't schedule a new WaitUntil if wait was cancelled (#1482) --- 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 a76f9f4f..13b5bcf8 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