pub struct AsyncMutex<T> { /* private fields */ }Expand description
Async-capable wrappers for OSAL primitives.
An async mutex protecting a value of type T.
§Fairness
This is a simple non-fair mutex: woken tasks compete to re-acquire the lock, so starvation is theoretically possible under high contention. For most embedded use-cases this is acceptable.
§Panics
Panics if the OS fails to allocate the internal binary semaphore.
Implementations§
Source§impl<T> AsyncMutex<T>
impl<T> AsyncMutex<T>
Sourcepub fn new(value: T) -> Self
pub fn new(value: T) -> Self
Creates a new AsyncMutex protecting value.
§Panics
Panics if the underlying OSAL semaphore cannot be created.
Sourcepub fn lock(&self) -> LockFuture<'_, T> ⓘ
pub fn lock(&self) -> LockFuture<'_, T> ⓘ
Returns a Future that resolves to an AsyncMutexGuard.
Trait Implementations§
impl<T: Send> Send for AsyncMutex<T>
impl<T: Send> Sync for AsyncMutex<T>
Auto Trait Implementations§
impl<T> !Freeze for AsyncMutex<T>
impl<T> !RefUnwindSafe for AsyncMutex<T>
impl<T> !UnwindSafe for AsyncMutex<T>
impl<T> Unpin for AsyncMutex<T>where
T: Unpin,
impl<T> UnsafeUnpin for AsyncMutex<T>where
T: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more