Utility locker
- simple named mutex/locker for rust-lang concurrency with no dependencies.
Basic usage of Locker
:
```rust use std::sync::Arc; use locker::Locker;
let locker = Arc::new(Locker::new()); let lockerclone = locker.clone(); let name = "name"; let first = locker.getmutex(name); // locks let _ = first.lock().unwrap(); std::thread::spawn(move || { let second = locker.get_mutex(name); let _ = second.lock().unwrap(); // wait // unlocks second mutex }); // unlocks first mutex ```
To run tests:
sh
cargo test -- --nocapture