commit | f1d1de14a0066d6dce4f355bbacade1d84f97d2d | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Wed Nov 22 00:13:55 2023 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Wed Nov 22 00:13:55 2023 +0000 |
tree | 7b96be3a97e36557820b6838dcd0ab5c52375c5e | |
parent | 6ba292b4229b0c3af198f315d79424a8e334f36f [diff] | |
parent | 7bb89187c5559dadc474598604a96cdd1ee08f6e [diff] |
Snap for 11130229 from 7bb89187c5559dadc474598604a96cdd1ee08f6e to 24Q1-release Change-Id: If9e60611ee42b9b5309a190c8d55e669be2e975e
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
.