Crates.io | proclock-api |
lib.rs | proclock-api |
version | 0.2.2 |
source | src |
created_at | 2022-03-16 12:58:27.144103 |
updated_at | 2022-03-17 22:01:15.297597 |
description | APIs for the proclock crate |
homepage | |
repository | https://github.com/tabnine/proclock |
max_upload_size | |
id | 551126 |
size | 4,038 |
Developed with ❤️ by Tabnine
It used to be proclock
, but it's been renamed to proc-lock.
Please update your dependencies to receive newer versions.
A simple cross-process locking API.
In your Cargo.toml
file, add:
[dependencies]
proclock = "*"
use proclock::{lock, LockPath};
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 proclock::proclock;
fn main() {
// A lock will be acquired at the beginning of this function, and will be released at the end.
a_sensitive_function();
}
#[proclock(name = "my_lock.lock")]
fn a_sensitive_function() {}
⚠️This crate is in its early stages, breaking changes are expected in upcoming releases.