[][src]Trait embedded_hal::mutex::RoMutex

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

A read-only (immutable) mutex.

This means, the value it shares is immutable, but only a single context may have exclusive access.

RwMutexes can implement this trait automatically using

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

Associated Types

type Error[]

Locking error

Required methods

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

Lock the mutex for the duration of a closure

lock will call a closure with an immutable reference to the unlocked mutex's value.

Implementors

impl<T, M> RoMutex<T> for M where
    M: DefaultRo + RwMutex<T>, 
[src][]

type Error = <M as RwMutex<T>>::Error