pub struct RawMutex { /* private fields */ }Expand description
A mutual exclusion primitive.
This lock disables interrupts on the current core while locked.
Implementations§
Source§impl RawMutex
impl RawMutex
Sourcepub unsafe fn acquire(&self) -> RestoreState
pub unsafe fn acquire(&self) -> RestoreState
Acquires the lock.
§Safety
- Each release call must be paired with an acquire call.
- The returned token must be passed to the corresponding
releasecall. - The caller must ensure to release the locks in the reverse order they were acquired.
Sourcepub unsafe fn release(&self, token: RestoreState)
pub unsafe fn release(&self, token: RestoreState)
Releases the lock.
§Safety
- This function must only be called if the lock was acquired by the current thread.
- The caller must ensure to release the locks in the reverse order they were acquired.
- Each release call must be paired with an acquire call.
Sourcepub fn lock_non_reentrant<R>(&self, f: impl FnOnce() -> R) -> R
pub fn lock_non_reentrant<R>(&self, f: impl FnOnce() -> R) -> R
Runs the callback with this lock locked.
Note that this function is not reentrant, calling it reentrantly will panic.
Trait Implementations§
Source§impl ScopedRawMutex for RawMutex
impl ScopedRawMutex for RawMutex
Source§fn with_lock<R>(&self, f: impl FnOnce() -> R) -> R
fn with_lock<R>(&self, f: impl FnOnce() -> R) -> R
Locks this mutex, runs f, and unlocks it.
§Panics
Panics if the current context already holds the lock.
Source§fn try_with_lock<R>(&self, f: impl FnOnce() -> R) -> Option<R>
fn try_with_lock<R>(&self, f: impl FnOnce() -> R) -> Option<R>
Lock this
ScopedRawMutex, calling f() after the lock has been acquired, and releasing
the lock after the completion of f(). Read more