fmutex

Crates.io Version Docs.rs Latest

Provides mutual exclusion on a file using flock(2).

Usage

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!");
}

} ```

License

Licensed under either of

at your option.