Skip to main content Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. Rust
  4. pw_kernel
  5. kernel
  6. BareSpinLock

BareSpinLock

Trait BareSpinLock 

Source
pub trait BareSpinLock: Send + Sync {
    type Guard<'a>
       where Self: 'a;

    const NEW: Self;

    // Required methods
    fn try_lock(&self) -> Option<Self::Guard<'_>>;
    unsafe fn adopt_locked(
        &self,
        interrupts_on_drop: InterruptsOnDrop,
    ) -> Self::Guard<'_>;

    // Provided method
    fn lock(&self) -> Self::Guard<'_> { ... }
}

Required Associated Constants§

Source

const NEW: Self

Required Associated Types§

Source

type Guard<'a>
where Self: 'a,

Required Methods§

Source

fn try_lock(&self) -> Option<Self::Guard<'_>>

Source

unsafe fn adopt_locked( &self, interrupts_on_drop: InterruptsOnDrop, ) -> Self::Guard<'_>

Reconstructs a guard for a lock that is already held by the current core (for example, when lock ownership is transferred across a context switch into a newly started thread’s entry trampoline).

Do not call directly.

interrupts_on_drop controls whether dropping the returned guard will re-enable interrupts after unlocking (InterruptsOnDrop::Restore) or leave interrupts disabled (InterruptsOnDrop::KeepDisabled).

§Safety

The caller must guarantee that the lock is currently held, interrupts are disabled, and no other active Guard will unlock it. See SpinLock::adopt_locked() for use and safety information.

Provided Methods§

Source

fn lock(&self) -> Self::Guard<'_>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§