commit | 3df313f3b483173178c5cae156be8ba212dd1850 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Thu Aug 08 01:13:21 2024 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Thu Aug 08 01:13:21 2024 +0000 |
tree | 2a298db21e4e275233744718ed9b21df26d9702d | |
parent | b1f50d68e4e6b5c4a39f001569d6284c0e993dae [diff] | |
parent | 178a9549e50222156ec96150da470ae3b0bee9c7 [diff] |
Snap for 12199973 from 178a9549e50222156ec96150da470ae3b0bee9c7 to 24Q4-release Change-Id: I197b693b3463f1def67bbd552fbbc187a3c2d7d7
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
.