Mutex

Struct Mutex 

Source
pub struct Mutex<T: ?Sized> { /* private fields */ }

Implementations§

Source§

impl<T: ?Sized> Mutex<T>

Source

pub fn lock_from_isr_explicit(&self) -> Result<MutexGuardFromIsr<'_, T>>

Acquires the mutex from ISR context, returning a specific ISR guard

Source§

impl<T> Mutex<T>

Source

pub fn new_arc(data: T) -> Arc<Self>

Creates a new mutex wrapped in an Arc for easy sharing between threads. This is a convenience method that combines Arc::new(Mutex::new(data)).

§Example
let shared_data = Mutex::new_arc(0u32);
let data_clone = Arc::clone(&shared_data);

Trait Implementations§

Source§

impl<T> Debug for Mutex<T>
where T: ?Sized,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Display for Mutex<T>
where T: ?Sized,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ?Sized> Mutex<T> for Mutex<T>

Source§

type Guard<'a> = MutexGuard<'a, T> where Self: 'a, T: 'a

Source§

type GuardFromIsr<'a> = MutexGuardFromIsr<'a, T> where Self: 'a, T: 'a

Source§

fn new(data: T) -> Self
where T: Sized,

Creates a new mutex wrapping the supplied data
Source§

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

Acquires the mutex, blocking the current thread until it is able to do so
Source§

fn lock_from_isr(&self) -> Result<Self::GuardFromIsr<'_>>

Acquires the mutex from ISR context
Source§

fn into_inner(self) -> Result<T>
where Self: Sized, T: Sized,

Attempts to consume this mutex, returning the underlying data
Source§

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

Returns a mutable reference to the underlying data
Source§

impl<T: ?Sized + Send> Send for Mutex<T>

Source§

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

Auto Trait Implementations§

§

impl<T> !Freeze for Mutex<T>

§

impl<T> !RefUnwindSafe for Mutex<T>

§

impl<T> Unpin for Mutex<T>
where T: Unpin + ?Sized,

§

impl<T> UnwindSafe for Mutex<T>
where T: UnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.