proclock/lib.rs
1//! ---
2//! # PLEASE NOTE: THIS CRATE HAS BEEN RENAMED
3//!
4//! It used to be `proclock`, but it's been renamed to [proc-lock](https://crates.io/crates/proc-lock).
5//!
6//! Please update your dependencies to receive newer versions.
7//!
8//! ---
9//!
10//! A simple cross-process locking API.
11//! # Implementation
12//! This crate uses [`fs2`](https://docs.rs/fs2) to exclusively lock files, and provides a convenient API to
13//! use this mechanism for synchronizing between multiple processes.
14//!
15//! # Quick Start
16//!
17//! ### Installation
18//! In your `Cargo.toml` file, add:
19//! ```toml
20//! [dependencies]
21//! proclock = "*"
22//! ```
23//!
24//! ### Using the API directly
25//! ```rust
26//! use proclock::{lock, LockPath};
27//!
28//! let lock_path = LockPath::Tmp("my_lock.lock");
29//! let guard = lock(&lock_path).unwrap();
30//! // Until `guard` is dropped, this code section is atomic across multiple processes.
31//! // ...
32//! drop(guard);
33//! ```
34//!
35//! ### Using macros
36//! ```rust
37//! use proclock::proclock;
38//!
39//! fn main() {
40//! // A lock will be acquired at the beginning of this function, and will be released at the end.
41//! a_sensitive_function();
42//! }
43//!
44//! #[proclock(name = "my_lock.lock")]
45//! fn a_sensitive_function() {}
46//! ```
47
48#[cfg(test)]
49mod tests;
50
51pub use proclock_api::*;
52pub use proclock_macro::*;