Provides mutual exclusion on a file using
flock(2)
.
lock()
```rust { let _guard = fmutex::lock(path)?;
// do mutually exclusive stuff here
} // <-- _guard
dropped here and the lock is released
```
try_lock()
```rust match fmutex::trylock(path)? { Some(guard) => {
// do mutually exclusive stuff here
} // <-- `_guard` dropped here and the lock is released
None => {
eprintln!("warn: the lock could not be acquired!");
}
} ```
Licensed under either of
at your option.