pub struct LazyData { /* private fields */ }Expand description
Lazy<T> storage — wraps an initializer closure (KindedSlot of
kind Ptr(HeapKind::Closure)) and a cached value slot. get()
runs the initializer the first time and caches the result;
subsequent calls return the cached value.
Closure-call dispatch (vm.call_value_immediate_nb) is unlocked by
the W17-make-closure partial-gate (merged at aa47364); see
executor/objects/concurrency_methods.rs::v2_lazy_get for the
closure-call body.
Mutex<LazyInner> for interior mutability: like ChannelData,
two Arc<LazyData> shares observe each other’s initialization
state. The OnceCell-style “init only happens once” guarantee is
preserved by the inner Mutex serializing concurrent get() calls
when the runtime grows real concurrency. At landing (single-
threaded VM) the mutex is uncontended.
Implementations§
Source§impl LazyData
impl LazyData
Sourcepub fn new(initializer: KindedSlot) -> Self
pub fn new(initializer: KindedSlot) -> Self
Build a LazyData wrapping initializer (expected to be a
closure KindedSlot).
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Whether get() has been called and the value cached.
Sourcepub fn cached(&self) -> Option<KindedSlot>
pub fn cached(&self) -> Option<KindedSlot>
Read the cached value if present, else None. The closure-call
path (running the initializer) lives in the handler tier — this
method is the storage-tier cache lookup. Returns a clone of the
cached slot (one strong-count share bumped).
Sourcepub fn take_initializer(&self) -> Option<KindedSlot>
pub fn take_initializer(&self) -> Option<KindedSlot>
Take the initializer closure (for the handler tier to invoke
via vm.call_value_immediate_nb). Returns None if the value
is already cached (caller should use cached() instead).
Sourcepub fn store_result(&self, value: KindedSlot)
pub fn store_result(&self, value: KindedSlot)
Cache the result of running the initializer. The initializer
slot has already been dropped (via take_initializer); this
installs the result. If a value was concurrently cached
(impossible at single-threaded landing, but defensive for
future concurrency), the new value drops cleanly via
KindedSlot::Drop.