mutex_trait

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

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

Source§

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>

Source§

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>

Source§

type Data = T