key-rwlock

Crates.iokey-rwlock
lib.rskey-rwlock
version0.1.2
sourcesrc
created_at2023-04-21 16:46:36.348473
updated_at2023-09-20 08:42:40.997663
descriptionSimple library for keyed asynchronous reader-writer locks
homepage
repositoryhttps://github.com/Defelo/key-rwlock
max_upload_size
id845486
size14,096
Felix Bargfeldt (Defelo)

documentation

https://docs.rs/key-rwlock/

README

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());
}
Commit count: 41

cargo fmt