Browse Source

Turn off randomness in tokio::select when more than one future is ready

pull/42/head
AzureMarker 3 years ago
parent
commit
8bf2b276cf
No known key found for this signature in database
GPG Key ID: 47A133F3BF9D03D3
  1. 5
      ctru-rs/examples/futures-tokio-basic.rs

5
ctru-rs/examples/futures-tokio-basic.rs

@ -38,12 +38,15 @@ fn main() {
let sleep_future = tokio::time::sleep_until(wake_time); let sleep_future = tokio::time::sleep_until(wake_time);
tokio::select! { tokio::select! {
_ = &mut exit_receiver => break, // Use the first available future instead of randomizing
biased;
_ = sleep_future => { _ = sleep_future => {
println!("Tick {}", iteration); println!("Tick {}", iteration);
iteration += 1; iteration += 1;
wake_time += Duration::from_secs(1); wake_time += Duration::from_secs(1);
} }
_ = &mut exit_receiver => break,
} }
} }
}); });

Loading…
Cancel
Save