Solve borrow checking by downgrading waitqueue lock
This commit is contained in:
+25
-1
@@ -12,7 +12,7 @@ use crate::{
|
||||
percpu::PercpuBlock,
|
||||
sync::{
|
||||
ArcRwLockWriteGuard, CleanLockToken, LockToken, RwLock, RwLockReadGuard, RwLockWriteGuard,
|
||||
L0, L1, L4,
|
||||
L0, L1, L2, L4,
|
||||
},
|
||||
syscall::error::Result,
|
||||
};
|
||||
@@ -234,3 +234,27 @@ impl Drop for PreemptGuardL1<'_> {
|
||||
self.context.write(self.token.token()).preempt_locks -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// Variant of PreemptGuard behind a one-level token
|
||||
pub struct PreemptGuardL2<'a> {
|
||||
context: &'a ContextLock,
|
||||
token: &'a mut LockToken<'a, L2>,
|
||||
}
|
||||
|
||||
impl<'a> PreemptGuardL2<'a> {
|
||||
pub fn new(context: &'a ContextLock, token: &'a mut LockToken<'a, L2>) -> PreemptGuardL2<'a> {
|
||||
context.write(token.token()).preempt_locks += 1;
|
||||
PreemptGuardL2 { context, token }
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the underlying `LockToken<L2>`.
|
||||
pub fn token(&mut self) -> &mut LockToken<'a, L2> {
|
||||
self.token
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for PreemptGuardL2<'_> {
|
||||
fn drop(&mut self) {
|
||||
self.context.write(self.token.token()).preempt_locks -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user