3 releases
0.1.2 | Sep 20, 2023 |
---|---|
0.1.1 | May 31, 2023 |
0.1.0 | Apr 21, 2023 |
#787 in Concurrency
74 downloads per month
8KB
113 lines
key-rwlock
Simple library for keyed asynchronous reader-writer locks.
Example
use key_rwlock::KeyRwLock;
#[tokio::main]
async fn main() {
let lock = KeyRwLock::new();
let _foo = lock.write("foo").await;
let _bar = lock.read("bar").await;
assert!(lock.try_read("foo").await.is_err());
assert!(lock.try_write("foo").await.is_err());
assert!(lock.try_read("bar").await.is_ok());
assert!(lock.try_write("bar").await.is_err());
}
Dependencies
~2–3MB
~46K SLoC