Try to call with_upgraded of RwLockUpgradableReadGuard twice in a single scope, but stuck on trying to aquire the lock on the second call. Example on rust playground
Here is a minimal problem reproduce
use parking_lot::RwLock;
struct Lock(RwLock<i32>);
fn main() {
let lock = Lock(RwLock::new(0));
let mut rl = lock.0.upgradable_read();
rl.with_upgraded(|_| {
println!("lock upgrade");
});
rl.with_upgraded(|_| {
println!("lock upgrade");
});
}
but success to aquire lock seperately like below
fn test_rwlock() {
use parking_lot::RwLock;
struct Lock(RwLock<i32>);
let lock = Lock(RwLock::new(0));
let rl = lock.0.read();
drop(rl);
let wl = lock.0.write();
trace!("lock upgrade");
drop(wl);
let wl = lock.0.write();
trace!("lock upgrade");
drop(wl);
}
Expectation
upgradable read lock rl can be access after with_upgraded was called, or can anyone confirm it is by design.
Enviroument
Problem
Try to call
with_upgraded
ofRwLockUpgradableReadGuard
twice in a single scope, but stuck on trying to aquire the lock on the second call. Example on rust playgroundHere is a minimal problem reproduce
but success to aquire lock seperately like below
Expectation
upgradable read lock
rl
can be access afterwith_upgraded
was called, or can anyone confirm it is by design.