Expand description
A Mutex
is prone to deadlocks when being used in sync and async code.
There are various causes of deadlocks, primarily due to not dropping the lock correctly.
This crate provides a function that locks for you, and automatically drops the lock. This significantly reduces the risk of deadlocks.
With this crate, you would convert .lock()
to simply be .with_lock(|s| *s)
.
§Features
- Simple API.
- Provides a Cell like struct powered by a Mutex:
MutexCell
.
§Caveats
If you manage to find a deadlock, please report it here.
This snippet would deadlock: s.with_Lock(|test| s.with_lock(|test2| test2))