pub type CriticalSectionMutex<T> = Mutex<CriticalSectionRawMutex, T>;
Expand description

A mutex that allows borrowing data across executors and interrupts.

Safety

This mutex is safe to share between different executors and interrupts.

Aliased Type§

struct CriticalSectionMutex<T> { /* private fields */ }

Implementations§

source§

impl<R: RawMutex, T> Mutex<R, T>

source

pub const fn new(val: T) -> Mutex<R, T>

Creates a new mutex in an unlocked state ready for use.

source

pub fn lock<U>(&self, f: impl FnOnce(&T) -> U) -> U

Creates a critical section and grants temporary access to the protected data.

source§

impl<R, T> Mutex<R, T>

source

pub const fn const_new(raw_mutex: R, val: T) -> Mutex<R, T>

Creates a new mutex based on a pre-existing raw mutex.

This allows creating a mutex in a constant context on stable Rust.

source

pub fn into_inner(self) -> T

Consumes this mutex, returning the underlying data.

source

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

Returns a mutable reference to the underlying data.

Since this call borrows the Mutex mutably, no actual locking needs to take place—the mutable borrow statically guarantees no locks exist.

source§

impl<T> Mutex<CriticalSectionRawMutex, T>

source

pub fn borrow<'cs>(&'cs self, _cs: CriticalSection<'cs>) -> &'cs T

Borrows the data for the duration of the critical section

Trait Implementations§

source§

impl<R: RawMutex + Send, T: ?Sized + Send> Send for Mutex<R, T>

source§

impl<R: RawMutex + Sync, T: ?Sized + Send> Sync for Mutex<R, T>