Qubit Lock
Lock-focused utilities for the Qubit Rust libraries. The crate provides synchronous and asynchronous lock wrappers plus monitor-style coordination.
Features
ArcMutex,ArcRwLock,ArcStdMutex: synchronous lock wrappers withArcbuilt in.ArcAsyncMutex,ArcAsyncRwLock: Tokio-based asynchronous lock wrappers.Monitor,ArcMonitor,MonitorGuard: parking_lot-based condition coordination.StdMonitor,ArcStdMonitor,StdMonitorGuard: std-based condition coordination.- Closure-based APIs that keep lock acquisition and release scoped to one call.
Arc*wrappers implementDerefandAsRef, so the native guard-based APIs of the wrapped primitive remain available when needed.
Installation
[]
= "0.4"
The async wrappers use Tokio synchronization primitives. If your application
creates a Tokio runtime, enable the appropriate Tokio runtime features in your
own Cargo.toml, such as rt or rt-multi-thread.
Quick Start
Synchronous lock
use ;
Native lock APIs
Arc* wrappers can still use the native lock APIs of their wrapped
primitives through Deref or AsRef.
use ;
For ArcRwLock and ArcAsyncRwLock, the closure-based read and write
methods have the same names as the native guard-based methods. When Lock or
AsyncLock is in scope, use lock.as_ref().read() or explicit dereferencing
such as (*lock).read() to call the native guard API.
Monitor
use ArcMonitor;
Project Layout
src/lock: lock traits and lock wrappers.src/monitor: parking_lot and std monitor primitives.tests/lock: lock behavior tests.tests/monitor: monitor behavior tests.tests/docs: README and doctext consistency tests.
Quality Checks
License
Apache-2.0