Expand description
§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 theShared
means 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 originalShared
and any derivedSharedReadLock
s to that value are dropped, it will be deallocated regardless of anyWeakReadLock
s. Must be upgraded intoSharedReadLock
to access the inner value.
Modules§
- lite
lite
- Versions of
Shared
andSharedReadLock
that are implemented in terms of the rclite crate. Becauserclite::Arc
doesn’t have weak references, there is noWeakReadLock
here.
Structs§
- Shared
- A wrapper around a resource possibly shared with
SharedReadLock
s andWeakReadLock
s, but no otherShared
s. - Shared
Read Guard - RAII structure used to release the shared read access of a lock when dropped.
- Shared
Read Lock - A read-only reference to a resource possibly shared with up to one
Shared
and manyWeakReadLock
s. - Shared
Write Guard - RAII structure used to release the exclusive write access of a lock when dropped.
- Weak
Read Lock - A weak read-only reference to a resource possibly shared with up to one
Shared
and manySharedReadLock
s.