pub struct Mutex<T: ?Sized> { /* private fields */ }Expand description
Represents an object which is protected by a FreeRTOS recursive mutex.
Implementations§
Source§impl<T: ?Sized> Mutex<T>
impl<T: ?Sized> Mutex<T>
Sourcepub fn lock(&self) -> MutexGuard<'_, T>
pub fn lock(&self) -> MutexGuard<'_, T>
Obtains a MutexGuard giving access to the object protected by the
mutex. Blocks until access can be obtained. Panics on failure; see
Mutex::try_lock().
§Behaviour
This function is blocking; it does not return until the the mutex is taken by the task, and allows other tasks to run in the meantime. Further, the task which currently holds the mutex actually inherits the current task’s priority, if it is higher; this prevents a high-priority task from being slowed down by waiting for a resource held by a low-priority task. See this documentation from FreeRTOS for details.
Sourcepub fn try_lock(&self) -> Result<MutexGuard<'_, T>, Error>
pub fn try_lock(&self) -> Result<MutexGuard<'_, T>, Error>
Obtains a MutexGuard giving access to the object protected by the
mutex. Blocks until access can be obtained; see Mutex::lock() for a
more thorough behavioural description.
Sourcepub fn poll(&self) -> Option<MutexGuard<'_, T>>
pub fn poll(&self) -> Option<MutexGuard<'_, T>>
Obtains a MutexGuard giving access to the object protected by the
mutex, if it is available immediately. Does not block.