pub trait Mutex: Sized {
// Required methods
fn new() -> Option<Self>;
fn lock(&self) -> MutexGuard<'_, Self>;
fn try_lock(&self) -> Option<MutexGuard<'_, Self>>;
fn unlock(&self, token: GuardToken);
}Expand description
Describes Mutex interface
Required Methods§
Sourcefn lock(&self) -> MutexGuard<'_, Self>
fn lock(&self) -> MutexGuard<'_, Self>
Acquires lock, returning guard that unlocks self on drop.
If lock is already acquired, it blocks until mutex is unlocked
Sourcefn try_lock(&self) -> Option<MutexGuard<'_, Self>>
fn try_lock(&self) -> Option<MutexGuard<'_, Self>>
Attempts to acquire lock, returning guard that unlocks self on drop.
If lock is already acquired, it returns None
Sourcefn unlock(&self, token: GuardToken)
fn unlock(&self, token: GuardToken)
Tells how to perform unlock.
Method implementation should be safe, but is allowed to mis-behave when invoked without
prior lock
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".