https://github.com/defelo/key-rwlock
Simple library for keyed asynchronous reader-writer locks
https://github.com/defelo/key-rwlock
Last synced: 3 months ago
JSON representation
Simple library for keyed asynchronous reader-writer locks
- Host: GitHub
- URL: https://github.com/defelo/key-rwlock
- Owner: Defelo
- License: mit
- Created: 2023-04-18T09:17:37.000Z (about 2 years ago)
- Default Branch: develop
- Last Pushed: 2024-02-01T14:17:24.000Z (over 1 year ago)
- Last Synced: 2024-03-23T11:24:00.246Z (about 1 year ago)
- Language: Rust
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/Defelo/key-rwlock/actions/workflows/check.yml)
[](https://github.com/Defelo/key-rwlock/actions/workflows/test.yml)
[](https://codecov.io/gh/Defelo/key-rwlock)

[](https://deps.rs/repo/github/Defelo/key-rwlock)# key-rwlock
Simple library for keyed asynchronous reader-writer locks.## Example
```rust
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());
}
```