Trait rtic::mutex::prelude::Mutex

source ·
pub trait Mutex {
    type T;

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

Memory safe access to shared resources

In RTIC, locks are implemented as critical sections that prevent other tasks from starting. These critical sections are implemented by temporarily increasing the dynamic priority of the current context. Entering and leaving these critical sections is always done in bounded constant time (a few instructions in bare metal contexts).

Required Associated Types§

source

type T

Data protected by the mutex

Required Methods§

source

fn lock<R>(&mut self, f: impl FnOnce(&mut Self::T) -> 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<'a, M> Mutex for &'a mut M
where M: Mutex,

§

type T = <M as Mutex>::T

source§

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

Implementors§

source§

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

§

type T = T