[][src]Trait embedded_hal::mutex::RwMutex

pub trait RwMutex<T>: Mutex<T> {
    type Error;
    fn lock_mut<R>(&self, f: impl FnOnce(&mut T) -> R) -> Result<R, Self::Error>;
}
[]

A read-write (mutable) mutex.

This mutex type is similar to the Mutex from std. When you lock it, you get access to a mutable reference.

This trait can automatically be implemented for RoMutex<RefCell<T>> by using

impl<T> mutex::default::RefCellRw for MyMutex<T> { }

Associated Types

type Error[]

Locking error

Required methods

fn lock_mut<R>(&self, f: impl FnOnce(&mut T) -> R) -> Result<R, Self::Error>[]

Lock the mutex for the duration of a closure

lock_mut will call a closure with a mutable reference to the unlocked mutex's value.

Implementors

impl<T, M> RwMutex<T> for M where
    M: RefCellRw + RoMutex<RefCell<T>> + Mutex<T>, 
[src][]

type Error = <M as RoMutex<RefCell<T>>>::Error