commit | ba666c9e7efe51b89cc194888963d213dc3ddebd | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Tue Sep 10 23:11:18 2024 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Tue Sep 10 23:11:18 2024 +0000 |
tree | 8e322710a83d00f4b65d262d22380afcd8f06912 | |
parent | 9031ba0cbd2fae75272dc0362fc12e4a61053ad0 [diff] | |
parent | e7b3982759e54ac2859ff94108b0a14390c5ff17 [diff] |
Snap for 12349386 from e7b3982759e54ac2859ff94108b0a14390c5ff17 to sdk-release Change-Id: I6a70111e4fc261f5d45f6d6aac37b7ce1aa3833a
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
.