From 8bf2b276cf15dad83b5ae280b83a373392088a26 Mon Sep 17 00:00:00 2001 From: AzureMarker Date: Sat, 5 Feb 2022 18:07:45 -0800 Subject: [PATCH] Turn off randomness in tokio::select when more than one future is ready --- ctru-rs/examples/futures-tokio-basic.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ctru-rs/examples/futures-tokio-basic.rs b/ctru-rs/examples/futures-tokio-basic.rs index 5260e7d..423a45f 100644 --- a/ctru-rs/examples/futures-tokio-basic.rs +++ b/ctru-rs/examples/futures-tokio-basic.rs @@ -38,12 +38,15 @@ fn main() { let sleep_future = tokio::time::sleep_until(wake_time); tokio::select! { - _ = &mut exit_receiver => break, + // Use the first available future instead of randomizing + biased; + _ = sleep_future => { println!("Tick {}", iteration); iteration += 1; wake_time += Duration::from_secs(1); } + _ = &mut exit_receiver => break, } } });