bilock 0.1.2

A minimal spin-lock based two-handle `Arc<Mutex<T>>` replacement
Documentation
  • Coverage
  • 100%
    24 out of 24 items documented24 out of 24 items with examples
  • Size
  • Source code size: 57.1 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 570.5 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Kijewski/bilock
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Kijewski

Bilock: a minimal spin-lock based two-handle Arc<Mutex<T>> replacement

GitHub Workflow Status Crates.io docs.rs

[Bilock::new()] provides two linked handles that share ownership of the same guarded value. A lock is held by either a temporary [Guard] or an [OwnedGuard], and the underlying value is released once both handles are dropped.

The library employs spin loops to wait for the lock, so it is intended for short critical sections only.

Example

use bilock::Bilock;

let (mut left, mut right) = Bilock::new(42);
let guard = left.lock();
assert_eq!(*guard, 42);
drop(guard);

let mut guard = right.lock();
*guard = 4711;
assert_eq!(*guard, 4711);

License

This project is tri-licensed under ISC OR MIT OR Apache-2.0. Contributions must be licensed under the same terms. Users may follow any one of these licenses, or all of them.

See the individual license texts at