fmutex 0.1.0

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

fmutex

Crates.io Version Docs.rs Latest

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

Usage

lock()

{
    let _guard = fmutex::lock(path)?;

    // do mutually exclusive stuff here

} // <-- `_guard` dropped here and the lock is released

try_lock()

match fmutex::try_lock(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.