commit | f16a72412f5f7047659dd896e1b95d5e52cb0f93 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Thu May 23 15:43:04 2024 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Thu May 23 15:43:04 2024 +0000 |
tree | 57d115b505e55dc06848c14d020d46b6c3b00c3c | |
parent | 5fbaf65805904dbb34766a670a45a98b9eb5aa59 [diff] | |
parent | b32bd00e6b1c717bb3e9bc53ca32c6a5423d39f3 [diff] |
Snap for 11880863 from b32bd00e6b1c717bb3e9bc53ca32c6a5423d39f3 to build-tools-release Change-Id: Icc3f3fbbe11cfc802bb770c50a504a3594815388
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
.