Crates.io | proc-lock-macro |
lib.rs | proc-lock-macro |
version | 0.4.0 |
source | src |
created_at | 2022-03-17 21:42:19.019367 |
updated_at | 2022-03-23 11:12:07.623668 |
description | Macro API for the proc-lock crate |
homepage | |
repository | https://github.com/tabnine/proc-lock |
max_upload_size | |
id | 552076 |
size | 3,664 |
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 :)