commit | 2ec479c7158e70420717811a409f15b799bb4513 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <[email protected]> | Wed Jul 24 17:52:55 2024 +0000 |
committer | Android Build Coastguard Worker <[email protected]> | Wed Jul 24 17:52:55 2024 +0000 |
tree | 57d115b505e55dc06848c14d020d46b6c3b00c3c | |
parent | 540b10afa394e2439b2d88829d7d93a2ce5898c8 [diff] | |
parent | e0016be474abe88fdc0ed58cafc32a327ec7993c [diff] |
Snap for 12134224 from e0016be474abe88fdc0ed58cafc32a327ec7993c to simpleperf-release Change-Id: I315042582323a109e05986420bf5868df77f9bf7
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
.