#reader-writer #locks #keyed #rwlock #key #async #tokio

key-rwlock

Simple library for keyed asynchronous reader-writer locks

3 releases

0.1.2 Sep 20, 2023
0.1.1 May 31, 2023
0.1.0 Apr 21, 2023

#787 in Concurrency

Download history 33/week @ 2024-03-11 28/week @ 2024-03-18 46/week @ 2024-03-25 79/week @ 2024-04-01 10/week @ 2024-04-08 22/week @ 2024-04-15 7/week @ 2024-04-22 32/week @ 2024-04-29 19/week @ 2024-05-06 8/week @ 2024-05-13 25/week @ 2024-05-20 18/week @ 2024-06-03 26/week @ 2024-06-10 18/week @ 2024-06-17 12/week @ 2024-06-24

74 downloads per month

MIT license

8KB
113 lines

check test codecov Version dependency status

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