commit | db58b92aac00bbb151a40e2ee4b39524d02edb33 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Wed Dec 13 00:11:51 2023 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Wed Dec 13 00:11:51 2023 +0000 |
tree | 7b96be3a97e36557820b6838dcd0ab5c52375c5e | |
parent | f010f33df705518c51052128dd39836b18a78d32 [diff] | |
parent | aec58de3216e67cf2b08eb657f4674c859e6f497 [diff] |
Snap for 11211409 from aec58de3216e67cf2b08eb657f4674c859e6f497 to sdk-release Change-Id: Ibac18aa622eb91b07a2263ec59694562ca5ccf25
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
.