Clone this repo:
  1. 7bb8918 Migrate to cargo_embargo. am: c7430c0513 am: d995cd8de6 am: 1bd86ed793 by Andrew Walbran · 5 months ago main master
  2. 7abde90 Migrate to cargo_embargo. am: c7430c0513 am: aec58de321 am: 840aa2b5ec by Andrew Walbran · 5 months ago
  3. 1bd86ed Migrate to cargo_embargo. am: c7430c0513 am: d995cd8de6 by Andrew Walbran · 5 months ago
  4. 840aa2b Migrate to cargo_embargo. am: c7430c0513 am: aec58de321 by Andrew Walbran · 5 months ago
  5. d995cd8 Migrate to cargo_embargo. am: c7430c0513 by Andrew Walbran · 5 months ago

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.