Crates.io | fmutex |
lib.rs | fmutex |
version | 0.1.0 |
source | src |
created_at | 2022-02-09 10:27:25.754116 |
updated_at | 2022-02-09 10:27:25.754116 |
description | Provides mutual exclusion on a file using flock(2) |
homepage | |
repository | https://github.com/rossmacarthur/fmutex |
max_upload_size | |
id | 529589 |
size | 19,071 |
Provides mutual exclusion on a file using
flock(2)
.
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!");
}
}
Licensed under either of
at your option.