-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Here's example code which causes deadlock without unsafe code.
extern crate futures;
extern crate qutex;
use qutex::*;
use futures::prelude::*;
fn main() {
let lock = QrwLock::from(0i32);
let f = lock.clone().write().and_then(move |mut guard_w| {
eprintln!("write lock acquired");
lock.read().and_then(move |guard_r| {
eprintln!("read lock acquired");
let r0 = *guard_r;
*guard_w += 1;
let r1 = *guard_r;
assert_eq!(r0, r1);
Ok(())
})
});
assert_eq!(Ok(()), f.wait());
}Is there any way to detect the deadlock? It would be nice for FutureGuard to return Deadlocked error (just like Canceled error) if there's any prior FutureGuard which belongs to current task. In that case, above example will return Error(Deadlocked) on f.wait() instead of hanging on deadlock.
Metadata
Metadata
Assignees
Labels
No labels