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.