Struct nb_sync::Mutex[][src]

pub struct Mutex<T> { /* fields omitted */ }

Mutex with interior mutability

This mutex assues that panic! is unrecoverable and crashes the program. This is a safe assumption for this embedded application since the panic! transforms into two udf instructions which result in a hard fault. If the user program incorporates any measures to recover from this sort of hard fault, this mutex is no longer safe since it does not implement the concept of "poisoning".

Since this mutex is polled and does not block, it is easy to have resource starvation occur. Care should be taken as to where the lock function is called to allow other tasks to have an opportunity to also grab the mutex.

Methods

impl<T> Mutex<T>
[src]

Creates a new mutex in the unlocked state

Attempts to lock the mutex

Once this function returns a MutexGuard, all other ongoing calls to try_lock will fail until the MutexGuard is Dropd.

Consumes this mutex and returns the underlying data

This is statically safe since we consume self.

Trait Implementations

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

Creates a new mutex from a value in an unlocked state

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

Auto Trait Implementations

impl<T> Send for Mutex<T> where
    T: Send