pub struct KMutexAliasedGuard<'a, Class1: LockClass, Class2: LockClass, M1: RawLock = RawMutex, M2: RawLock = M1, P: LockPolicy<M1> = <M1 as RawLock>::DefaultPolicy> { /* private fields */ }Expand description
A validation guard representing ownership of two aliased locks simultaneously.
Only the first lock is physically acquired, but proof tokens for both lock classes (Class1 and
Class2) are provided.
Implementations§
Source§impl<'a, Class1: LockClass, Class2: LockClass, M1: RawLock, M2: RawLock, P: LockPolicy<M1>> KMutexAliasedGuard<'a, Class1, Class2, M1, M2, P>
impl<'a, Class1: LockClass, Class2: LockClass, M1: RawLock, M2: RawLock, P: LockPolicy<M1>> KMutexAliasedGuard<'a, Class1, Class2, M1, M2, P>
Source§impl<'a, Class1: LockClass, Class2: LockClass, M1: RawLock, M2: RawLock, P: LockPolicy<M1>> KMutexAliasedGuard<'a, Class1, Class2, M1, M2, P>
impl<'a, Class1: LockClass, Class2: LockClass, M1: RawLock, M2: RawLock, P: LockPolicy<M1>> KMutexAliasedGuard<'a, Class1, Class2, M1, M2, P>
Sourcepub fn new(
lock1: &'a KMutex<Class1, M1>,
lock2: &'a KMutex<Class2, M2>,
) -> impl PinInit<Self, Infallible>where
P: LockPolicy<M1, AcquireArgs = ()>,
pub fn new(
lock1: &'a KMutex<Class1, M1>,
lock2: &'a KMutex<Class2, M2>,
) -> impl PinInit<Self, Infallible>where
P: LockPolicy<M1, AcquireArgs = ()>,
Creates a new stack-pinned aliased validation guard initialization block.
Sourcepub fn new_with_args(
lock1: &'a KMutex<Class1, M1>,
_lock2: &'a KMutex<Class2, M2>,
args: P::AcquireArgs,
) -> impl PinInit<Self, Infallible>
pub fn new_with_args( lock1: &'a KMutex<Class1, M1>, _lock2: &'a KMutex<Class2, M2>, args: P::AcquireArgs, ) -> impl PinInit<Self, Infallible>
Creates a new stack-pinned aliased validation guard initialization block with policy acquire arguments.
Sourcepub fn tokens(&self) -> (&LockToken<'a, Class1>, &LockToken<'a, Class2>)
pub fn tokens(&self) -> (&LockToken<'a, Class1>, &LockToken<'a, Class2>)
Returns shared references to both lock proof tokens (Class1, Class2).
Sourcepub unsafe fn tokens_mut(
self: Pin<&mut Self>,
) -> (&mut LockToken<'a, Class1>, &mut LockToken<'a, Class2>)
pub unsafe fn tokens_mut( self: Pin<&mut Self>, ) -> (&mut LockToken<'a, Class1>, &mut LockToken<'a, Class2>)
Returns simultaneous mutable references to both proof tokens (Class1, Class2).
§Safety
Both returned tokens are backed by a single physical lock acquisition. The caller must
ensure that the two mutable tokens are not used to obtain aliasing mutable references to
the same KCell or KOnceCell (for example, by passing both tokens to guard_<lock>_mut
on the same struct instance).
Sourcepub fn token(&self) -> &LockToken<'a, Class1>
pub fn token(&self) -> &LockToken<'a, Class1>
Returns a shared reference to the primary lock proof token (Class1).
Sourcepub fn token_mut(self: Pin<&mut Self>) -> &mut LockToken<'a, Class1>
pub fn token_mut(self: Pin<&mut Self>) -> &mut LockToken<'a, Class1>
Returns a mutable reference to the primary lock proof token (Class1).
Sourcepub fn inner_guard(
self: Pin<&mut Self>,
) -> Pin<&mut KMutexGuard<'a, Class1, M1, P>>
pub fn inner_guard( self: Pin<&mut Self>, ) -> Pin<&mut KMutexGuard<'a, Class1, M1, P>>
Returns a pinned mutable reference to the primary inner KMutexGuard.
Sourcepub fn release(self: Pin<&mut Self>)
pub fn release(self: Pin<&mut Self>)
Explicitly releases the underlying lock before the guard is dropped.
If the lock has already been released, this is a no-op.
Sourcepub fn call_unlocked<R, F: FnOnce() -> R>(self: Pin<&mut Self>, f: F) -> R
pub fn call_unlocked<R, F: FnOnce() -> R>(self: Pin<&mut Self>, f: F) -> R
Temporarily releases the lock before executing the given callable f and then
re-acquires the lock.
Sourcepub fn call_untracked<R, F: FnOnce(&mut LockToken<'a, Class1>) -> R>(
self: Pin<&mut Self>,
f: F,
) -> R
pub fn call_untracked<R, F: FnOnce(&mut LockToken<'a, Class1>) -> R>( self: Pin<&mut Self>, f: F, ) -> R
Calls a closure while temporarily disabling lockdep tracking for the lock held by this guard.
Trait Implementations§
Source§impl<'a, Class1: LockClass, Class2: LockClass, M1: RawLock, M2: RawLock, P: LockPolicy<M1>> HasPinData for KMutexAliasedGuard<'a, Class1, Class2, M1, M2, P>
impl<'a, Class1: LockClass, Class2: LockClass, M1: RawLock, M2: RawLock, P: LockPolicy<M1>> HasPinData for KMutexAliasedGuard<'a, Class1, Class2, M1, M2, P>
Auto Trait Implementations§
impl<'a, Class1, Class2, M1 = RawMutex, M2 = M1, P = <M1 as RawLock>::DefaultPolicy> !Send for KMutexAliasedGuard<'a, Class1, Class2, M1, M2, P>
impl<'a, Class1, Class2, M1 = RawMutex, M2 = M1, P = <M1 as RawLock>::DefaultPolicy> !Sync for KMutexAliasedGuard<'a, Class1, Class2, M1, M2, P>
impl<'a, Class1, Class2, M1, M2, P> Freeze for KMutexAliasedGuard<'a, Class1, Class2, M1, M2, P>
impl<'a, Class1, Class2, M1, M2, P> RefUnwindSafe for KMutexAliasedGuard<'a, Class1, Class2, M1, M2, P>where
<M1 as RawLock>::LockEntry: RefUnwindSafe,
<P as LockPolicy<M1>>::GuardState: RefUnwindSafe,
M2: RefUnwindSafe,
M1: RefUnwindSafe,
Class2: RefUnwindSafe,
Class1: RefUnwindSafe,
impl<'a, Class1, Class2, M1, M2, P> UnsafeUnpin for KMutexAliasedGuard<'a, Class1, Class2, M1, M2, P>
impl<'a, Class1, Class2, M1, M2, P> UnwindSafe for KMutexAliasedGuard<'a, Class1, Class2, M1, M2, P>where
<M1 as RawLock>::LockEntry: UnwindSafe,
<P as LockPolicy<M1>>::GuardState: UnwindSafe,
M2: RefUnwindSafe,
M1: RefUnwindSafe,
Class2: RefUnwindSafe,
Class1: RefUnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), !>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), !>
slot. Read moreSource§fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where
F: FnOnce(Pin<&mut T>) -> Result<(), E>,
fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where
F: FnOnce(Pin<&mut T>) -> Result<(), E>,
self then calls the function f with the initialized
value. Read more