pub struct StaticMutex<T: ?Sized> { /* private fields */ }Expand description
A statically-allocated mutex for protecting shared data.
Similar to Mutex<T> but designed to be allocated at compile time
as a static variable. Requires explicit initialization before use.
§Examples
ⓘ
use osal_rs::os::StaticMutex;
static mut COUNTER_MUTEX: Option<StaticMutex<u32>> = None;
// During initialization:
unsafe {
COUNTER_MUTEX = Some(StaticMutex::new(0).unwrap());
}Implementations§
Trait Implementations§
Source§impl<T> StaticMutex<T> for StaticMutex<T>
impl<T> StaticMutex<T> for StaticMutex<T>
Source§fn lock(&self) -> Result<StaticMutexGuard<'_, T>>
fn lock(&self) -> Result<StaticMutexGuard<'_, T>>
Acquires the lock and returns a guard.
Blocks until the lock is available.
Source§fn lock_from_isr(&self) -> Result<StaticMutexGuardFromIsr<'_, T>>
fn lock_from_isr(&self) -> Result<StaticMutexGuardFromIsr<'_, T>>
Acquires the lock from ISR context and returns an ISR guard.
Non-blocking version for interrupt service routines.
Source§fn get_mut(&mut self) -> &mut T
fn get_mut(&mut self) -> &mut T
Returns a mutable reference to the underlying data.
Safe because it requires exclusive mutable access to the mutex.
Source§type Guard<'a> = StaticMutexGuard<'a, T>
where
Self: 'a,
T: 'a
type Guard<'a> = StaticMutexGuard<'a, T> where Self: 'a, T: 'a
Guard type returned by
lock(), providing RAII-style mutex access. Read moreSource§type GuardFromIsr<'a> = StaticMutexGuardFromIsr<'a, T>
where
Self: 'a,
T: 'a
type GuardFromIsr<'a> = StaticMutexGuardFromIsr<'a, T> where Self: 'a, T: 'a
Guard type returned by
lock_from_isr(), for ISR-context mutex access. Read moreAuto Trait Implementations§
impl<T> !Freeze for StaticMutex<T>
impl<T> !RefUnwindSafe for StaticMutex<T>
impl<T> Send for StaticMutex<T>
impl<T> !Sync for StaticMutex<T>
impl<T> Unpin for StaticMutex<T>
impl<T> UnwindSafe for StaticMutex<T>where
T: UnwindSafe + ?Sized,
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