commit | 929e226fee09c140d318b58624b6878bcb1dca82 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Thu Aug 29 23:11:26 2024 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Thu Aug 29 23:11:26 2024 +0000 |
tree | 8e322710a83d00f4b65d262d22380afcd8f06912 | |
parent | 3df313f3b483173178c5cae156be8ba212dd1850 [diff] | |
parent | 64b8eefb946acc0e42a6ec367a429b1d0720287b [diff] |
Snap for 12296955 from 64b8eefb946acc0e42a6ec367a429b1d0720287b to 24Q4-release Change-Id: I515d97c98471dc3a778a983d4abb4b3fede0fc4e
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
.