Struct cooptex::CoopMutex [−][src]
pub struct CoopMutex<T> { /* fields omitted */ }
Expand description
A deadlock-free version of Mutex
.
This is only deadlock-free if:
- All Mutexes that may deadlock are
CoopMutex
es - When
Retry
is returned, the requesting thread drops all otherMutexGuard
s it is holding. Easily accomplished withretry_loop
.
Implementations
Acquire a mutex or return Err(Retry)
, indicating that the current thread should drop all
its currently held locks and try to acquire them again. Use retry_loop
to automatically
use the correct behavior.
Panics
Panics when a thread attempts to acquire a lock it is already holding.
Returns a mutable reference to the underlying data.
See std::sync::Mutex
for more details of implications.