commit | 941f0d157cc720134706762948a6c150785a3092 | [log] [tgz] |
---|---|---|
author | James Farrell <[email protected]> | Wed Aug 28 16:52:42 2024 +0000 |
committer | James Farrell <[email protected]> | Wed Aug 28 16:52:42 2024 +0000 |
tree | 8e322710a83d00f4b65d262d22380afcd8f06912 | |
parent | 78e8e5d81c11f58086161d91b8562a7873473878 [diff] |
Migrate 25 crates to monorepo. miette mime mio mls-rs-codec mls-rs-codec-derive mls-rs-core mockall named-lock nom no-panic num_cpus num-integer num-traits oorandom os_str_bytes p9 p9_wire_format_derive parking_lot parking_lot_core pathdiff pdl-runtime pest pest_derive pest_generator pest_meta Bug: 339424309 Test: treehugger Change-Id: I618a9a1c5405da2e693d515817b1c3698ed415f2
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
.