A weird alternative to
Arc<RwLock<T>>
- Rust 100%
| .cargo | Replace GitHub actions by xtask | |
| .vscode | Add lite module | |
| readlock | Publish readlock v0.1.11 and readlock-tokio v0.1.6 | |
| readlock-tokio | Publish readlock v0.1.11 and readlock-tokio v0.1.6 | |
| xtask | Replace GitHub actions by xtask | |
| .gitignore | Initial commit | |
| .rustfmt.toml | Initial commit | |
| Cargo.toml | Update package metadata | |
| LICENSE | Initial commit | |
| README.md | Upgrade rclite | |
readlock
(Shared) Read-Only Lock: A thing that can be useful when you don't really want shared mutability, you just want to mutate a value from one place and read it from many others.
This library provides three types:
Shared<T>: similar toArc<RwLock<T>>, but you can only createSharedReadLock<T>s andWeakReadLock<T>s from it that share access to the same inner value, not furtherShared<T>s. Also, acquiring a write lock requires unique ownership / borrowing (&mut self). However: Reading requires no locking because mutably borrowing theSharedmeans that no other thread can be mutating the value at the same time (all other reference to the value are read-only).SharedReadLock<T>: like aArc<RwLock<T>>that is only ever used for reading. Can be downgraded toWeakReadLock.WeakReadLock<T>: like aWeak<RwLock<T>>. That is, it references the same memory, but if the originalSharedand any derivedSharedReadLocks to that value are dropped, it will be deallocated regardless of anyWeakReadLocks. Must be upgraded intoSharedReadLockto access the inner value.