Snap for 12349386 from e7b3982759e54ac2859ff94108b0a14390c5ff17 to sdk-release Change-Id: I6a70111e4fc261f5d45f6d6aac37b7ce1aa3833a
This crate provides a simple and cross-platform implementation of named locks. You can use this to lock sections between processes.
use named_lock::NamedLock; use named_lock::Result; fn main() -> Result<()> { let lock = NamedLock::create("foobar")?; let _guard = lock.lock()?; // Do something... Ok(()) }
On UNIX this is implemented by using files and flock. The path of the created lock file will be $TMPDIR/<name>.lock, or /tmp/<name>.lock if TMPDIR environment variable is not set.
On Windows this is implemented by creating named mutex with CreateMutexW.