pub struct RawSpinLock<T>(/* private fields */)
where
T: ?Sized;Expand description
A non-sleeping mutual-exclusion lock.
The lock object does not bake in an execution-context policy. Callers
choose the policy at the acquisition site with Self::lock,
Self::lock_irqsave, or Self::lock_raw.
Implementations§
Source§impl<T> RawSpinLock<T>
impl<T> RawSpinLock<T>
Sourcepub const fn new(data: T) -> RawSpinLock<T>
pub const fn new(data: T) -> RawSpinLock<T>
Creates an unlocked spin lock.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the lock and returns the protected value.
Source§impl<T> RawSpinLock<T>where
T: ?Sized,
impl<T> RawSpinLock<T>where
T: ?Sized,
Sourcepub fn lock(&self) -> BaseSpinLockGuard<'_, PreemptState, T>
pub fn lock(&self) -> BaseSpinLockGuard<'_, PreemptState, T>
Acquires the lock after disabling kernel preemption.
Sourcepub fn lock_nested(
&self,
subclass: u32,
) -> BaseSpinLockGuard<'_, PreemptState, T>
pub fn lock_nested( &self, subclass: u32, ) -> BaseSpinLockGuard<'_, PreemptState, T>
Acquires the lock after disabling preemption, using a lockdep subclass.
This is intended for structurally nested acquisitions of different
locks with the same class. Without lockdep, subclass has no effect.
Sourcepub fn try_lock(&self) -> Option<BaseSpinLockGuard<'_, PreemptState, T>>
pub fn try_lock(&self) -> Option<BaseSpinLockGuard<'_, PreemptState, T>>
Attempts to acquire the lock after disabling kernel preemption.
Sourcepub fn lock_irqsave(&self) -> BaseSpinLockGuard<'_, PreemptIrqSaveState, T>
pub fn lock_irqsave(&self) -> BaseSpinLockGuard<'_, PreemptIrqSaveState, T>
Acquires the lock after disabling preemption and saving/disabling IRQs.
Sourcepub fn lock_irqsave_nested(
&self,
subclass: u32,
) -> BaseSpinLockGuard<'_, PreemptIrqSaveState, T>
pub fn lock_irqsave_nested( &self, subclass: u32, ) -> BaseSpinLockGuard<'_, PreemptIrqSaveState, T>
Acquires the lock after disabling preemption and saving/disabling IRQs, using a lockdep subclass.
This is intended for structurally nested acquisitions of different
locks with the same class. Without lockdep, subclass has no effect.
Sourcepub fn try_lock_irqsave(
&self,
) -> Option<BaseSpinLockGuard<'_, PreemptIrqSaveState, T>>
pub fn try_lock_irqsave( &self, ) -> Option<BaseSpinLockGuard<'_, PreemptIrqSaveState, T>>
Attempts to acquire the lock after disabling preemption and IRQs.
Sourcepub unsafe fn lock_raw(&self) -> BaseSpinLockGuard<'_, RawState, T>
pub unsafe fn lock_raw(&self) -> BaseSpinLockGuard<'_, RawState, T>
Acquires the lock without changing preemption or interrupt state.
§Safety
The caller must prevent same-CPU re-entry and all concurrent access which could violate exclusive access, including on single-core builds where the atomic lock word is compiled out.
Sourcepub unsafe fn try_lock_raw(&self) -> Option<BaseSpinLockGuard<'_, RawState, T>>
pub unsafe fn try_lock_raw(&self) -> Option<BaseSpinLockGuard<'_, RawState, T>>
Attempts a raw acquisition without changing execution context.
§Safety
The caller must uphold the same exclusion contract as
Self::lock_raw, even when this function returns None.