Crates.io | semalock |
lib.rs | semalock |
version | 0.3.1 |
source | src |
created_at | 2018-05-12 02:14:53.257421 |
updated_at | 2020-02-26 04:17:31.927003 |
description | A library for concurrently writing to files in a safe and efficient manner. |
homepage | https://github.com/longshorej/semalock |
repository | https://github.com/longshorej/semalock |
max_upload_size | |
id | 64956 |
size | 27,387 |
semalock is a Rust library for controlling concurrent access to files on POSIX operating systems in an efficient manner.
It uses a combination of POSIX named semaphores and exclusive file locks to safely and efficiently acquire exclusive access to a file. This has been observed to be particularly efficient on Linux, with under 5% of CPU time spent on lock overhead with 8192 processes.
The following shows usage of semalock. This program opens /some/file
and appends some text to it. Try it with GNU parallel to measure performance amongst multiple competing processes.
// Acquire and open a file and semaphore
let mut lock = Semalock::new(Path::new("/some/file"));
// Do some stuff to the file
lock.with(|lock| {
lock.file
.seek(SeekFrom::End())
.and_then(|_| lock.file.write(b"hello world\n"))
});
The following operating systems have been tested:
The following operating systems have not been tested but should work:
Supported operating systems must support provide the following:
The following will not work:
Semalock::with
now takes an FnOnce
instead of an Fn
.To run the tests, execute the following:
cargo test
To release the create, perform the following:
Cargo.toml
, bumping the version as appropriate.README.md
, adding an entry to the Release Notes.master
.Jason Longshore hello@jasonlongshore.com