commit | a294f64df21fe96f3b3b5bb8001327eb97ba3595 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Sun May 26 07:09:55 2024 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Sun May 26 07:09:55 2024 +0000 |
tree | 57d115b505e55dc06848c14d020d46b6c3b00c3c | |
parent | 26d538512a01886d63b43ca8c38046adef184983 [diff] | |
parent | 1cd6d382042160f8e85f8846b65b2a366e3aa902 [diff] |
Snap for 11878398 from 1cd6d382042160f8e85f8846b65b2a366e3aa902 to busytown-mac-infra-release Change-Id: I886336fce2ee407ba60561944fdeaed309f34dd9
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
.