Crates.io | proc-lock-api |
lib.rs | proc-lock-api |
version | 0.4.0 |
source | src |
created_at | 2022-03-17 21:40:58.758482 |
updated_at | 2022-03-23 11:11:52.323158 |
description | APIs for the proc-lock crate |
homepage | |
repository | https://github.com/tabnine/proc-lock |
max_upload_size | |
id | 552074 |
size | 4,047 |
Developed with ❤️ by Tabnine
A simple cross-process locking API.
In your Cargo.toml
file, add:
[dependencies]
proc-lock = "*"
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);
}
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() {}
⚠️This crate is in its early stages, breaking changes are expected in upcoming releases.
proc-lock
, and the macro to proc_lock
Please refer to our project, as well as open issues.
Also feel free to discuss and open PRs regardless :)