Migrate to cargo_embargo. am: c7430c0513

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

Change-Id: I9d67b17b8ca7beff7ba19b21b81e90e65eb6b0ce
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
tree: 7b96be3a97e36557820b6838dcd0ab5c52375c5e
  1. src/
  2. Android.bp
  3. Cargo.toml
  4. Cargo.toml.orig
  5. cargo_embargo.json
  6. CHANGELOG.md
  7. LICENSE
  8. METADATA
  9. MODULE_LICENSE_MIT
  10. OWNERS
  11. README.md
  12. 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.