1 unstable release

0.1.0 Feb 9, 2022

#1139 in Filesystem

Download history 82/week @ 2024-07-21 95/week @ 2024-07-28 112/week @ 2024-08-04 232/week @ 2024-08-11 208/week @ 2024-08-18 394/week @ 2024-08-25 166/week @ 2024-09-01 192/week @ 2024-09-08 115/week @ 2024-09-15 223/week @ 2024-09-22 146/week @ 2024-09-29 135/week @ 2024-10-06 124/week @ 2024-10-13 85/week @ 2024-10-20 133/week @ 2024-10-27 295/week @ 2024-11-03

648 downloads per month
Used in 2 crates

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

~44KB