commit | 2e667848695d2e0a89909d56edaf919d564dd35a | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Sat May 11 01:13:24 2024 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Sat May 11 01:13:24 2024 +0000 |
tree | 283552f8d8387f8f7c90405d46e120e4d081aba4 | |
parent | 7bb89187c5559dadc474598604a96cdd1ee08f6e [diff] | |
parent | a73a0c4f8c161b1391398a9d12fda465f8c8a29e [diff] |
Snap for 11828632 from a73a0c4f8c161b1391398a9d12fda465f8c8a29e to 24Q3-release Change-Id: Ic5aa544e88e87b844b2b2c91ba0eba991be782a6
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
.