Comment by skavi
6 hours ago
If do_async_thing was implemented as below, i can’t imagine the futurelock post getting anywhere near this much attention. As for why you might use an async lock in a future which acquires and unlocks in the same poll, there still may be other actors which hold the lock across multiple polls. (there is one in the RFD’s minimized example).
async fn do_async_thing(label: &str, lock: Arc<Mutex<()>>) {
println!("{label}: started");
let _guard = lock.lock().await;
println!("{label}: acquired lock");
sleep(Duration::from_secs(5)).await;
println!("{label}: done");
}
No comments yet
Contribute on Hacker News ↗