fmutex

Crates.iofmutex
lib.rsfmutex
version0.1.0
sourcesrc
created_at2022-02-09 10:27:25.754116
updated_at2022-02-09 10:27:25.754116
descriptionProvides mutual exclusion on a file using flock(2)
homepage
repositoryhttps://github.com/rossmacarthur/fmutex
max_upload_size
id529589
size19,071
Ross MacArthur (rossmacarthur)

documentation

README

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.

Commit count: 4

cargo fmt