pub struct Mutex { /* private fields */ }Expand description
A mutual exclusion primitive useful for protecting shared data.
This mutex will block tasks waiting for the lock to become available.
Implementations§
Source§impl Mutex
impl Mutex
Sourcepub fn new(name: &str) -> Result<Self>
pub fn new(name: &str) -> Result<Self>
Creates a new OSAL mutex in the unlocked (available) state.
§Arguments
name: A unique string to identify the mutex.
Sourcepub fn lock(&self) -> Result<MutexGuard<'_>>
pub fn lock(&self) -> Result<MutexGuard<'_>>
Acquires a mutex, blocking the current task until it is able to do so.
This function returns a MutexGuard when the lock has been acquired.
The guard ensures that the lock is automatically released when it goes out of scope.
Sourcepub fn get_id_by_name(name: &str) -> Result<OsalId>
pub fn get_id_by_name(name: &str) -> Result<OsalId>
Finds an existing mutex ID by its name.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mutex
impl RefUnwindSafe for Mutex
impl Send for Mutex
impl Sync for Mutex
impl Unpin for Mutex
impl UnsafeUnpin for Mutex
impl UnwindSafe for Mutex
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