commit | b1f50d68e4e6b5c4a39f001569d6284c0e993dae | [log] [tgz] |
---|---|---|
author | James Farrell <[email protected]> | Wed May 22 23:28:05 2024 +0000 |
committer | Automerger Merge Worker <[email protected]> | Wed May 22 23:28:05 2024 +0000 |
tree | 57d115b505e55dc06848c14d020d46b6c3b00c3c | |
parent | a73a0c4f8c161b1391398a9d12fda465f8c8a29e [diff] | |
parent | e0016be474abe88fdc0ed58cafc32a327ec7993c [diff] |
Update Android.bp by running cargo_embargo am: b32bd00e6b am: e0016be474 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/named-lock/+/3096238 Change-Id: Ifd5c52362585db4c005bc84a9542afe5d64e2512 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
.