pub struct SpinLock<T> {
    locked: AtomicBool,
    inner: UnsafeCell<T>,
}Expand description
A tiny spinlock for short critical sections.
This lock is suitable for uniprocessor or early boot stages where:
- Preemption is either disabled or non-existent.
 - Critical sections are very short (no I/O, no blocking).
 
§Guarantees
- Provides mutual exclusion for access to the protected value.
 Syncis implemented whenT: Send, allowing shared references across threads (the lock enforces interior mutability).
§Caveats
- Does not disable interrupts.
 - Busy-waits with 
spin_loop, so keep critical sections small. 
Fields§
§locked: AtomicBoolLock state (false = unlocked, true = locked).
inner: UnsafeCell<T>The protected value.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for SpinLock<T>
impl<T> !RefUnwindSafe for SpinLock<T>
impl<T> Send for SpinLock<T>where
    T: Send,
impl<T> Unpin for SpinLock<T>where
    T: Unpin,
impl<T> UnwindSafe for SpinLock<T>where
    T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more