commit | 9031ba0cbd2fae75272dc0362fc12e4a61053ad0 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Thu Aug 29 01:11:27 2024 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Thu Aug 29 01:11:27 2024 +0000 |
tree | 8e322710a83d00f4b65d262d22380afcd8f06912 | |
parent | e6c8cef0c23ae7a022e60510aadc02074d51cf1f [diff] | |
parent | 941f0d157cc720134706762948a6c150785a3092 [diff] |
Snap for 12291954 from 941f0d157cc720134706762948a6c150785a3092 to sdk-release Change-Id: I56eb4cb7481b57ea88b24b3da8139a1e7ef6ec50
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
.