double-checked-cell-2.0.1 doesn't have any documentation.
double-checked-cell
A thread-safe lazily initialized cell using double-checked locking.
Introduction
Provides a memory location that can be safely shared between threads and initialized at most once. Once the cell is initialized it becomes immutable.
If you do not need to change the value after initialization
DoubleCheckedCell<T>
is more efficient than a Mutex<Option<T>>
.
extern crate double_checked_cell;
use DoubleCheckedCell;
Related crates
These crates are similar but distinct by design:
- lazy-init – Based on a
LazyTransform<T, U>
which can lazily consumeT
to produce anU
. Therefore cannot support fallible initialization. - lazycell –
AtomicLazyCell
does not support lazy initialization (unlike its non-thread-safe counterpartLazyCell
usingLazyCell::borrow_with()
). - mitochondria – Not
Sync
. - once_cell - Based on
std::sync::Once
. Therefore cannot support fallible initialization. - lazy_static - With the optional (currently nightly only)
const_fn
feature,DoubleCheckedCell::new()
can also be used in static/const context. Howeverlazy_static!
is more convenient when there is only a single way to initialize the cell.
Documentation
Changelog
- 2.0.1
- Update to parking_lot 0.7.
- 2.0.0
- Changed unwinding behavior:
DoubleCheckedCell
no longer implements poisoning. - New optional cargo features:
parking_lot_mutex
,const_fn
.
- Changed unwinding behavior:
- 1.1.0
- Fix unsoundness:
DoubleCheckedCell<T>
whereT: !Send
cannot beSync
.
- Fix unsoundness:
- 1.0.1
- Ignore
unused_unsafe
warning due toUnsafeCell::into_inner()
no longer beeing unsafe.
- Ignore
- 1.0.0
- Initial release.
License
double-checked-cell is licensed under the Apache 2.0 and MIT license, at your option.