Module postgresfixture::lock
source · Expand description
File-based locking using flock(2)
.
You must start with an UnlockedFile
.
let lock_dir = tempdir::TempDir::new("locks")?;
let mut lock = UnlockedFile::try_from(lock_dir.path().join("foo").as_path())?;
let lock = lock.lock_shared()?;
let lock = lock.lock_exclusive()?;
let lock = lock.unlock()?;
Dropping a LockedFileShared
or LockedFileExclusive
drops their locks
too, by virtue of dropping the File
they each wrap, so there’s no need
to call unlock
unless you prefer to be explicit.