#process #inter-process #flock #cross-process #create-mutex-w

named-lock

Cross-platform implementation of cross-process named locks

2 releases

0.1.1 Feb 8, 2020
0.1.0 Feb 7, 2020

#177 in Operating systems

Download history 11201/week @ 2021-09-29 34764/week @ 2021-10-06 26616/week @ 2021-10-13 12928/week @ 2021-10-20 14853/week @ 2021-10-27 11628/week @ 2021-11-03 13772/week @ 2021-11-10 3944/week @ 2021-11-17 2574/week @ 2021-11-24 1271/week @ 2021-12-01 336/week @ 2021-12-08 390/week @ 2021-12-15 319/week @ 2021-12-22 384/week @ 2021-12-29 571/week @ 2022-01-05 486/week @ 2022-01-12

1,851 downloads per month

MIT license

13KB
259 lines

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 systems this is implemented by using files and flock. The path of the created lock file will be /tmp/<name>.lock.

On Windows this is implemented by creating named mutex with CreateMutexW.

Dependencies

~0.9–1.5MB
~32K SLoC