Migrate 25 crates to monorepo. am: 941f0d157c

Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/named-lock/+/3248336

Change-Id: I3f019a0950b0595823bfc57d41ae0e06bf6dd9f9
Signed-off-by: Automerger Merge Worker <[email protected]>
tree: 8e322710a83d00f4b65d262d22380afcd8f06912
  1. src/
  2. Android.bp
  3. Cargo.toml
  4. Cargo.toml.orig
  5. CHANGELOG.md
  6. LICENSE
  7. METADATA
  8. MODULE_LICENSE_MIT
  9. OWNERS
  10. README.md
  11. rustfmt.toml
README.md

named-lock

license crates.io docs

This crate provides a simple and cross-platform implementation of named locks. You can use this to lock sections between processes.

Example

use named_lock::NamedLock;
use named_lock::Result;

fn main() -> Result<()> {
    let lock = NamedLock::create("foobar")?;
    let _guard = lock.lock()?;

    // Do something...

    Ok(())
}

Implementation

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.