commit | aaea0878178334718dc55fd3745c0f8a538a43af | [log] [tgz] |
---|---|---|
author | Bob Badour <bbadour@google.com> | Thu May 04 08:24:44 2023 -0700 |
committer | Bob Badour <bbadour@google.com> | Thu May 04 08:24:44 2023 -0700 |
tree | 83dae2a80d085f22951e1f33744a6d79277c7e3d | |
parent | 6ebd4d16ce86e64052dd4f5466ecca4bf798e18e [diff] |
[LSC] Add LOCAL_LICENSE_KINDS to external/rust/crates/named-lock Added SPDX-license-identifier-MIT to: Android.bp Bug: 68860345 Bug: 151177513 Bug: 151953481 Test: m all Change-Id: I7d4b88ae00ce5a703a2ddaa64d32cdb7fb4bc200
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
.