commit | 09f6164e91f650c81ffc490dcf96b0b1069ab2eb | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Tue Aug 20 17:57:38 2024 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Tue Aug 20 17:57:38 2024 +0000 |
tree | 2a298db21e4e275233744718ed9b21df26d9702d | |
parent | 2ec479c7158e70420717811a409f15b799bb4513 [diff] | |
parent | 78e8e5d81c11f58086161d91b8562a7873473878 [diff] |
Snap for 12252487 from 78e8e5d81c11f58086161d91b8562a7873473878 to simpleperf-release Change-Id: I67526d6b67105b5db4d1b55ee281a0fa217298a5
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
.