GMTX
GMTX is a Rust crate that provides Gutex type for protecting shared data similar to
std::sync::Mutex.
The std::sync::Mutex and the related types are prone to deadlock when using on a multiple struct
fields like this:
use Mutex;
The order to acquire the lock must be the same everywhere otherwise the deadlock is possible. Maintaining the lock order manually are cumbersome task so we invent this crate to handle this instead.
How this crate are working is simple. Any locks on any Gutex will lock the same mutex in the
group, which mean there are only one mutex in the group. It have the same effect as the following
code:
use Mutex;
The bonus point of Gutex is it will allow recursive lock for read-only access so you will never
end up deadlock yourself. This read-only access is per Gutex. It will panic if you try to acquire
write access while the readers are still active the same as std::cell::RefCell.
Example
use ;
License
This project is licensed under either of
- Apache License, Version 2.0
- MIT License
at your option.