commit | a4a4433ce644a42e66833843f9d1c3ac00554249 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Thu May 23 23:14:02 2024 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Thu May 23 23:14:02 2024 +0000 |
tree | 57d115b505e55dc06848c14d020d46b6c3b00c3c | |
parent | 2e667848695d2e0a89909d56edaf919d564dd35a [diff] | |
parent | b1f50d68e4e6b5c4a39f001569d6284c0e993dae [diff] |
Snap for 11881322 from b1f50d68e4e6b5c4a39f001569d6284c0e993dae to 24Q3-release Change-Id: I19673ee4cbdc2059eb029f232461a0807c072f6d
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
.