#locking #api #cross-process

proc-lock

A simple cross-process locking API

5 releases

0.4.0 Mar 23, 2022
0.3.3 Mar 22, 2022
0.3.2 Mar 17, 2022
0.3.1 Mar 17, 2022
0.3.0 Mar 17, 2022

#799 in Concurrency

Download history 550/week @ 2024-01-01 811/week @ 2024-01-08 1178/week @ 2024-01-15 970/week @ 2024-01-22 1212/week @ 2024-01-29 1031/week @ 2024-02-05 927/week @ 2024-02-12 909/week @ 2024-02-19 893/week @ 2024-02-26 803/week @ 2024-03-04 893/week @ 2024-03-11 845/week @ 2024-03-18 1465/week @ 2024-03-25 643/week @ 2024-04-01 1127/week @ 2024-04-08 1138/week @ 2024-04-15

4,518 downloads per month
Used in 4 crates (3 directly)

MIT license

7KB
78 lines

Developed with ❤️ by Tabnine

Proc-lock

A simple cross-process locking API.

Quick Start

Installation

In your Cargo.toml file, add:

[dependencies]
proc-lock = "*"

Using the API directly

use proc_lock::{lock, LockPath};

fn main() {
    let lock_path = LockPath::Tmp("my_lock.lock");
    let guard = lock(&lock_path).unwrap();
    // Until `guard` is dropped, this code section is atomic across multiple processes.
    // ...
    drop(guard);
}

Using macros

use proc_lock::proclock;

fn main() {
 // A lock will be acquired at the beginning of this function, and will be released at the end.
 a_sensitive_function();
}

#[proc_lock(name = "my_lock.lock")]
fn a_sensitive_function() {}

Current status

⚠️This crate is in its early stages, breaking changes are expected in upcoming releases.

Changelog

  • 0.4.0 - Change interdependencies to local for better development process
  • 0.3.3 - Minor docs changes
  • 0.3.2 - Fix macro compilation
  • 0.3.1 - Change docs
  • 0.3.0 - [breaking changes] Rename crate to proc-lock, and the macro to proc_lock
  • 0.2.1 - Add a notice about renaming the crate
  • 0.2.0 - [breaking changes] Stop supporting non-blocking macro api

Contribution

Please refer to our project, as well as open issues.

Also feel free to discuss and open PRs regardless :)

Dependencies

~1.4–2MB
~42K SLoC