Skip to main content

try_lock

Function try_lock 

Source
pub fn try_lock<T: ?Sized>(mutex: &Mutex<T>) -> Option<MutexGuard<'_, T>>
Expand description

lock, but gives up rather than waiting when the mutex is already held.

None means “someone else has it right now”, not “it is broken”: a poisoned but free mutex still yields its guard, for the reason lock documents.