pub struct MutexImp { /* private fields */ }
Expand description
Simple mutex, supporting sleeping and wakeup. Does no attempt at handling priority or fairness.
Implementations§
Source§impl MutexImp
impl MutexImp
pub fn is_locked(&self) -> bool
Sourcepub unsafe fn lock(&self, caller: &'static Location<'static>)
pub unsafe fn lock(&self, caller: &'static Location<'static>)
Lock a mutex, which can be unlocked by calling [Mutex::unlock].
§Safety
The caller must ensure that they are not recursively locking, that they unlock the mutex correctly, and that any data protected by the mutex is only accessed with the mutex locked.
Note, this is why you should use the standard library mutex, which enforces all of these things.
Sourcepub unsafe fn unlock(&self)
pub unsafe fn unlock(&self)
Unlock a mutex locked with Mutex::lock.
§Safety
Must be the current owner of the locked mutex and must make sure to unlock properly.
Sourcepub unsafe fn try_lock(&self) -> bool
pub unsafe fn try_lock(&self) -> bool
Similar to Mutex::lock, but if we can’t immediately grab the lock, don’t and return false. Return true if we got the lock.
§Safety
Same safety concerns as Mutex::lock, but now you have to check to see if the lock happened or not.