Skip to main content

RawSpinLock

Struct RawSpinLock 

Source
pub struct RawSpinLock<T: ?Sized>(/* private fields */);
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>

Source

pub const fn new(data: T) -> Self

Creates an unlocked spin lock.

Source

pub fn into_inner(self) -> T

Consumes the lock and returns the protected value.

Source§

impl<T: ?Sized> RawSpinLock<T>

Source

pub fn lock(&self) -> RawSpinLockGuard<'_, T>

Acquires the lock after disabling kernel preemption.

Source

pub fn lock_nested(&self, subclass: u32) -> RawSpinLockGuard<'_, 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.

Source

pub fn try_lock(&self) -> Option<RawSpinLockGuard<'_, T>>

Attempts to acquire the lock after disabling kernel preemption.

Source

pub fn lock_irqsave(&self) -> RawSpinLockIrqSaveGuard<'_, T>

Acquires the lock after disabling preemption and saving/disabling IRQs.

Source

pub fn lock_irqsave_nested( &self, subclass: u32, ) -> RawSpinLockIrqSaveGuard<'_, 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.

Source

pub fn try_lock_irqsave(&self) -> Option<RawSpinLockIrqSaveGuard<'_, T>>

Attempts to acquire the lock after disabling preemption and IRQs.

Source

pub unsafe fn lock_raw(&self) -> RawSpinLockUnpinnedGuard<'_, 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.

Source

pub unsafe fn try_lock_raw(&self) -> Option<RawSpinLockUnpinnedGuard<'_, 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.

Source

pub fn is_locked(&self) -> bool

Returns whether the lock appears held.

This is only a diagnostic snapshot and provides no synchronization.

Source

pub fn get_mut(&mut self) -> &mut T

Returns mutable access without locking.

Trait Implementations§

Source§

impl<T: Debug> Debug for RawSpinLock<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for RawSpinLock<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for RawSpinLock<T>

§

impl<T> !RefUnwindSafe for RawSpinLock<T>

§

impl<T> Send for RawSpinLock<T>
where BaseSpinLock<RawState, T>: Send, T: ?Sized,

§

impl<T> Sync for RawSpinLock<T>
where BaseSpinLock<RawState, T>: Sync, T: ?Sized,

§

impl<T> Unpin for RawSpinLock<T>
where BaseSpinLock<RawState, T>: Unpin, T: ?Sized,

§

impl<T> UnsafeUnpin for RawSpinLock<T>
where BaseSpinLock<RawState, T>: UnsafeUnpin, T: ?Sized,

§

impl<T> UnwindSafe for RawSpinLock<T>
where BaseSpinLock<RawState, T>: UnwindSafe, T: ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.