kernel::synchronization::interface

Trait Mutex

Source
pub trait Mutex {
    type Data;

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

Any object implementing this trait guarantees exclusive access to the data wrapped within the Mutex for the duration of the provided closure.

Required Associated Types§

Source

type Data

The type of the data that is wrapped by this mutex.

Required Methods§

Source

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

Locks the mutex and grants the closure temporary mutable access to the wrapped 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.

Implementors§

Source§

impl<T> Mutex for NullLock<T>

Source§

type Data = T