commit | 540b10afa394e2439b2d88829d7d93a2ce5898c8 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Fri Feb 02 23:54:00 2024 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Fri Feb 02 23:54:00 2024 +0000 |
tree | 7b96be3a97e36557820b6838dcd0ab5c52375c5e | |
parent | c9e6c46b8a0677c5959c12f509f1eaed238fc0c9 [diff] | |
parent | aec58de3216e67cf2b08eb657f4674c859e6f497 [diff] |
Snap for 11400057 from aec58de3216e67cf2b08eb657f4674c859e6f497 to simpleperf-release Change-Id: Ibafffeb0d09bcdbdce7bcbedcd4146400d46adc4
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
.