proc_lock/lib.rs
1//! A simple cross-process locking API.
2//! # Implementation
3//! This crate uses [`fs2`](https://docs.rs/fs2) to exclusively lock files, and provides a convenient API to
4//! use this mechanism for synchronizing between multiple processes.
5//!
6//! # Quick Start
7//!
8//! ### Installation
9//! In your `Cargo.toml` file, add:
10//! ```toml
11//! [dependencies]
12//! proc-lock = "*"
13//! ```
14//!
15//! ### Using the API directly
16//! ```rust
17//! use proc_lock::{lock, LockPath};
18//!
19//! let lock_path = LockPath::Tmp("my_lock.lock");
20//! let guard = lock(&lock_path).unwrap();
21//! // Until `guard` is dropped, this code section is atomic across multiple processes.
22//! // ...
23//! drop(guard);
24//! ```
25//!
26//! ### Using macros
27//! ```rust
28//! use proc_lock::proc_lock;
29//!
30//! fn main() {
31//! // A lock will be acquired at the beginning of this function, and will be released at the end.
32//! a_sensitive_function();
33//! }
34//!
35//! #[proc_lock(name = "my_lock.lock")]
36//! fn a_sensitive_function() {}
37//! ```
38
39pub use proc_lock_api::*;
40pub use proc_lock_macro::*;