commit | 6ba292b4229b0c3af198f315d79424a8e334f36f | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Tue Nov 21 00:12:31 2023 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Tue Nov 21 00:12:31 2023 +0000 |
tree | 7b96be3a97e36557820b6838dcd0ab5c52375c5e | |
parent | 86f712f6c887e722e2acc81b37f18d526ca3229b [diff] | |
parent | 7abde901493660e484533d9b49e20338bb3078b2 [diff] |
Snap for 11124398 from 7abde901493660e484533d9b49e20338bb3078b2 to 24Q1-release Change-Id: Ic383285d3ee3481be3d3af487820310962368986
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
.