Expand description
This crate provides the LockCell<T> and other supportings types.
A LockCell is a cell type which provides dynamic mutation using interior
mutability. It is similar to RefCell<T>, except that it only allows
a single borrow type (a lock). Locking a LockCell allows mutating its
contents freely.
A LockCell can only be used in a single threaded context - it cannot be sent or
shared across different threads. Generally, a LockCell will be stored in a Rc<T>
so that it can be shared.
Whether you use a LockCell or a RefCell depends on the structure and behavior of
your program. Generally, if you have a lot of writers and readers, using a LockCell
may be better, as it ensures that writers are less likely to be starved.
Structs
- A mutable memory location with dynamically checked borrow rules.
- A
LockGuardprovides exclusive access to the inner value of aLockCell<T>. - An error returned from the
LockCell::try_lock()method to indicate that theLockCellcould not be locked.