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").unwrap();
let mut lock = UnlockedFile::try_from(lock_dir.path().join("foo").as_path()).unwrap();
let lock = lock.lock_shared().unwrap();
let lock = lock.lock_exclusive().unwrap();
let lock = lock.unlock().unwrap();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.