pub struct EmbeddedMutex<T: Send + Sync> { /* private fields */ }
Implementations§
Source§impl<T: Send + Sync> EmbeddedMutex<T>
impl<T: Send + Sync> EmbeddedMutex<T>
pub const fn new(input: T) -> Self
Sourcepub unsafe fn try_get(&self) -> Option<&mut T>
pub unsafe fn try_get(&self) -> Option<&mut T>
Attempts to acquire the mutex without blocking.
§Safety
This function is unsafe
because it returns a mutable reference to the
inner value without tying its lifetime to the lock state. The caller must
ensure that:
- No other mutable or immutable references to the inner value exist while this reference is in use.
return_mutex()
is called exactly once after the reference is no longer needed, before any other thread or interrupt attempts to acquire the lock.
Failure to follow these rules results in undefined behavior.
Returns Some(&mut T)
if the lock was successfully acquired, or None
if
it was already held.
pub fn return_mutex(&self)
Trait Implementations§
impl<T: Send + Sync> Send for EmbeddedMutex<T>
impl<T: Send + Sync> Sync for EmbeddedMutex<T>
Auto Trait Implementations§
impl<T> !Freeze for EmbeddedMutex<T>
impl<T> !RefUnwindSafe for EmbeddedMutex<T>
impl<T> Unpin for EmbeddedMutex<T>where
T: Unpin,
impl<T> UnwindSafe for EmbeddedMutex<T>where
T: UnwindSafe,
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