commit | fd38d35251b4fcb0089e133a21185901a3cdbc40 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Wed Sep 11 23:28:54 2024 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Wed Sep 11 23:28:54 2024 +0000 |
tree | 8e322710a83d00f4b65d262d22380afcd8f06912 | |
parent | 7a4c8c456c51807c8e1048f53b4c14d19f1d0363 [diff] | |
parent | e7b3982759e54ac2859ff94108b0a14390c5ff17 [diff] |
Snap for 12355814 from e7b3982759e54ac2859ff94108b0a14390c5ff17 to build-tools-release Change-Id: I6448aaa04dab4da87429f9ea210d4e5c745bf294
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
.