Skip to main content

LazyData

Struct LazyData 

Source
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

Source

pub fn new(initializer: KindedSlot) -> Self

Build a LazyData wrapping initializer (expected to be a closure KindedSlot).

Source

pub fn is_initialized(&self) -> bool

Whether get() has been called and the value cached.

Source

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).

Source

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).

Source

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.

Trait Implementations§

Source§

impl Debug for LazyData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,