tag | 6cbf95d75221a62891d516bf42f3392f343c76c3 | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Tue Apr 23 15:27:25 2024 -0700 |
object | 26d538512a01886d63b43ca8c38046adef184983 |
Platform Tools Release 35.0.1 (11580240)
commit | 26d538512a01886d63b43ca8c38046adef184983 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Thu Mar 07 02:16:03 2024 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Thu Mar 07 02:16:03 2024 +0000 |
tree | 7b96be3a97e36557820b6838dcd0ab5c52375c5e | |
parent | db58b92aac00bbb151a40e2ee4b39524d02edb33 [diff] | |
parent | 7bb89187c5559dadc474598604a96cdd1ee08f6e [diff] |
Snap for 11541002 from 7bb89187c5559dadc474598604a96cdd1ee08f6e to sdk-release Change-Id: I4dc1efb50b01af6f779c62297b459886f41f322e
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
.