#keyed #reader-writer #locks #rwlock #async #key #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

#973 in Concurrency

Download history 9/week @ 2024-07-29 11/week @ 2024-08-05 37/week @ 2024-08-12 19/week @ 2024-08-19 23/week @ 2024-08-26 33/week @ 2024-09-02 73/week @ 2024-09-09 4/week @ 2024-09-16 54/week @ 2024-09-23 7/week @ 2024-09-30 9/week @ 2024-10-07 49/week @ 2024-10-14 21/week @ 2024-10-21 83/week @ 2024-10-28 105/week @ 2024-11-04 20/week @ 2024-11-11

236 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–8MB
~47K SLoC