Solve borrow checking by downgrading waitqueue lock
This commit is contained in:
@@ -6,8 +6,8 @@ use alloc::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
context::{self, ContextLock, PreemptGuard, PreemptGuardL1},
|
||||
sync::{CleanLockToken, LockToken, Mutex, L1, L3},
|
||||
context::{self, ContextLock, PreemptGuard, PreemptGuardL1, PreemptGuardL2},
|
||||
sync::{CleanLockToken, LockToken, Mutex, L1, L2, L3},
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -59,6 +59,16 @@ impl WaitCondition {
|
||||
guard: T,
|
||||
reason: &'static str,
|
||||
token: &'a mut LockToken<'a, L1>,
|
||||
) -> bool {
|
||||
let mut token = token.downgrade();
|
||||
self.wait_inner(guard, reason, &mut token)
|
||||
}
|
||||
|
||||
pub fn wait_inner<'a, T>(
|
||||
&self,
|
||||
guard: T,
|
||||
reason: &'static str,
|
||||
token: &'a mut LockToken<'a, L2>,
|
||||
) -> bool {
|
||||
let current_context_ref = context::current();
|
||||
{
|
||||
@@ -67,7 +77,7 @@ impl WaitCondition {
|
||||
// We cannot add ourselves to the wait list first as that would lead
|
||||
// to deadlock if we were woken up immediately.
|
||||
let mut token = token.token();
|
||||
let mut preempt = PreemptGuardL1::new(¤t_context_ref, &mut token);
|
||||
let mut preempt = PreemptGuardL2::new(¤t_context_ref, &mut token);
|
||||
let token = preempt.token();
|
||||
{
|
||||
let mut context = current_context_ref.write(token.token());
|
||||
|
||||
Reference in New Issue
Block a user