Oxide RFD 06090
async fn loop_select_three_guards_break_outside(
lock1: Arc<Mutex<i32>>,
lock2: Arc<Mutex<i32>>,
lock3: Arc<Mutex<i32>>,
) {
let mut fut1 = async { lock1.lock().await; 1 }.boxed();
let mut fut2 = async { lock2.lock().await; 2 }.boxed();
let mut fut3 = async { lock3.lock().await; 3 }.boxed();
let mut fut1_finished = false;
let mut fut2_finished = false;
let mut fut3_finished = false;
loop {
tokio::select! {
result = &mut fut1, if !fut1_finished => {
fut1_finished = true;
println!("fut1 done: {}", result);
}
result = &mut fut2, if !fut2_finished => {
fut2_finished = true;
println!("fut2 done: {}", result);
}
result = &mut fut3, if !fut3_finished => {
fut3_finished = true;
println!("fut3 done: {}", result);
}
}
if fut1_finished && fut2_finished && fut3_finished {
break;
}
}
sleep(Duration::from_secs(1)).await;
}Timeline view - select any point to travel.
Kek
We begin…
This is a paragraph to shift layout when switching to & away from this higlight.
Arm 1 finishes first
If not taken.
Second iteration
Completing fut2 now.
Completing fut2 now.
Sleeping at the last await;
Sleeping at the last await;
Arm 1 finishes first
If not taken.
Second iteration
Completing fut2 now.
Sleeping at the last await;
puts 3.inspect