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]
impl<T> Mutex<T>
pub const fn new(val: T) -> Self
[src]
pub const fn new(val: T) -> Self
Creates a new mutex in the unlocked state
pub fn lock(&self, _cs: &CriticalSection) -> Result<MutexGuard<T>, !>
[src]
pub fn lock(&self, _cs: &CriticalSection) -> Result<MutexGuard<T>, !>
Attempts to lock the mutex
Once this function returns a MutexGuard
, all other ongoing calls to try_lock
will fail
until the MutexGuard
is Drop
d.
pub fn into_inner(self) -> T
[src]
pub fn into_inner(self) -> T
Consumes this mutex and returns the underlying data
This is statically safe since we consume self
.