Utility locker
- simple async/sync locker for rust concurrency.
```rust use std::time::Duration; use locker::AsyncLocker; use tokio::time::delay_for;
let locker = AsyncLocker::new(); let mutex = locker.getmutex(1).await; let _guard = mutex.lock().await; // lock let lockerclone = locker.clone(); tokio::spawn(async move { let mutex = locker.getmutex(1).await; let _guard = mutex.lock().await; // wait }); delayfor(Duration::from_millis(200)).await; ```
```rust use std::time::Duration; use std::thread; use locker::SyncLocker;
let locker = SyncLocker::new(); let mutex = locker.getmutex(1); let _guard = mutex.lock().unwrap(); // lock let lockerclone = locker.clone(); thread::spawn(move || { let mutex = locker.getmutex(1); let _guard = mutex.lock().unwrap(); // wait }); thread::sleep(Duration::frommillis(200)); ```
To run tests:
sh
cargo test -- --nocapture