commit | 1ea30e22e3484e44050a4dbf36ee64f89f640f08 | [log] [tgz] |
---|---|---|
author | James Farrell <jamesfarrell@google.com> | Wed May 08 21:35:59 2024 +0000 |
committer | James Farrell <jamesfarrell@google.com> | Wed May 08 21:35:59 2024 +0000 |
tree | 283552f8d8387f8f7c90405d46e120e4d081aba4 | |
parent | 7bb89187c5559dadc474598604a96cdd1ee08f6e [diff] |
Update Android.bp by running cargo_embargo Test: ran cargo_embargo Change-Id: I5f0063c758d2a463ebeee62ec0ce3dec72632812
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
.