Trait max7301::mutex::IOMutex[][src]

pub trait IOMutex<T> {
    fn new(v: T) -> Self;
fn lock<R, F: FnOnce(&mut T) -> R>(&self, f: F) -> R; }

Any type that can implement IOMutex can be used as a mutex for synchronizing access to the I/O device (either pins in an expander, or multiple expanders on a bus).

If the std feature is enabled, then IOMutex is implemented for std::sync::Mutex. If cortexm is enabled, then IOMutex is implemented for cortex_m::interrupt::Mutex<core::cell::RefCell> (the RefCell is needed to add mutability which the mutex does not provide for some reason).

If either of these features is enabled, then the type alias DefaultMutex<T> will point to the corresponding mutex type to use.

Required methods

fn new(v: T) -> Self[src]

Construct a new instance of this mutex containing the value v.

fn lock<R, F: FnOnce(&mut T) -> R>(&self, f: F) -> R[src]

Lock the mutex and call the closure f as a critical section, passing a mutable reference to the owned value. Returns the value returned by f.

Loading content...

Implementations on Foreign Types

impl<T> IOMutex<T> for Mutex<T>[src]

Loading content...

Implementors

Loading content...