commit | 8361f6a13f50dcdaf6d26d778c02575c51fde9f0 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Sun Sep 15 07:11:27 2024 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Sun Sep 15 07:11:27 2024 +0000 |
tree | 8e322710a83d00f4b65d262d22380afcd8f06912 | |
parent | b0dcab936cd909b4fe54c53ef698ab1e4e16de40 [diff] | |
parent | ba666c9e7efe51b89cc194888963d213dc3ddebd [diff] |
Snap for 12356763 from ba666c9e7efe51b89cc194888963d213dc3ddebd to busytown-mac-infra-release Change-Id: Idf9ab821684a5e7ec5725e6bcc01bcd59490a4c9
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
.