commit | a73a0c4f8c161b1391398a9d12fda465f8c8a29e | [log] [tgz] |
---|---|---|
author | James Farrell <[email protected]> | Thu May 09 20:27:11 2024 +0000 |
committer | Automerger Merge Worker <[email protected]> | Thu May 09 20:27:11 2024 +0000 |
tree | 283552f8d8387f8f7c90405d46e120e4d081aba4 | |
parent | 7bb89187c5559dadc474598604a96cdd1ee08f6e [diff] | |
parent | 5465fcf05c799f9b99e4f21e39669e572384306c [diff] |
Update Android.bp by running cargo_embargo am: 1ea30e22e3 am: 5465fcf05c Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/named-lock/+/3079319 Change-Id: If6f4d5cf85c843b1948286c70e100997f3c895f0 Signed-off-by: Automerger Merge Worker <[email protected]>
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
.