commit | 64b8eefb946acc0e42a6ec367a429b1d0720287b | [log] [tgz] |
---|---|---|
author | James Farrell <[email protected]> | Wed Aug 28 22:26:24 2024 +0000 |
committer | Automerger Merge Worker <[email protected]> | Wed Aug 28 22:26:24 2024 +0000 |
tree | 8e322710a83d00f4b65d262d22380afcd8f06912 | |
parent | 178a9549e50222156ec96150da470ae3b0bee9c7 [diff] | |
parent | e7b3982759e54ac2859ff94108b0a14390c5ff17 [diff] |
Migrate 25 crates to monorepo. am: 941f0d157c am: e7b3982759 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/named-lock/+/3248336 Change-Id: I0e852ed42eef3ac82ab7d1d2110d90f9847d6011 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
.