1 unstable release

0.1.0 Feb 9, 2022

#5 in #flock

Download history 70/week @ 2024-01-07 81/week @ 2024-01-14 130/week @ 2024-01-21 48/week @ 2024-01-28 71/week @ 2024-02-04 48/week @ 2024-02-11 82/week @ 2024-02-18 57/week @ 2024-02-25 94/week @ 2024-03-03 62/week @ 2024-03-10 84/week @ 2024-03-17 76/week @ 2024-03-24 135/week @ 2024-03-31 70/week @ 2024-04-07 88/week @ 2024-04-14 102/week @ 2024-04-21

409 downloads per month
Used in sheldon

MIT/Apache

7KB
79 lines

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.

Dependencies

~43KB