Trait mutex_trait::Mutex

source ·
pub trait Mutex {
    type Data;

    // Required method
    fn lock<R>(&mut self, f: impl FnOnce(&mut Self::Data) -> R) -> R;
}
Expand description

Any object implementing this trait guarantees exclusive access to the data contained within the mutex for the duration of the lock.

Required Associated Types§

source

type Data

Data protected by the mutex.

Required Methods§

source

fn lock<R>(&mut self, f: impl FnOnce(&mut Self::Data) -> R) -> R

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

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<L> Mutex for &mut L
where L: Mutex,

§

type Data = <L as Mutex>::Data

source§

fn lock<R>(&mut self, f: impl FnOnce(&mut Self::Data) -> R) -> R

source§

impl<T> Mutex for &RefCell<T>

§

type Data = T

source§

fn lock<R>(&mut self, f: impl FnOnce(&mut T) -> R) -> R

Implementors§

source§

impl<'a, T> Mutex for Exclusive<'a, T>

§

type Data = T