Skip to content

Cross-platform implementation of cross-process named locks

License

Notifications You must be signed in to change notification settings

superlistapp/named-lock

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Cross-platform implementation of cross-process named locks

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%