UnsafeAtomicLazyReference

An unsafe reference type holding a lazily initializable atomic strong reference, requiring manual memory management of the underlying storage representation.

UnsafeAtomicLazyReference.swift:20UnsafeAtomicLazyReference.md
@frozen struct UnsafeAtomicLazyReference<Instance> where Instance : AnyObject

These values can be set (initialized) exactly once, but read many times.

Related Types

  • typealias Value

    The value logically stored in an atomic lazy reference value.

Initializers

Shorthand Methods for Dynamically Allocating Storage

Atomic Operations

  • func load() -> Instance?

    Atomically loads and returns the current value of this reference.

  • func storeIfNilThenLoad(Instance) -> Instance

    Atomically initializes this reference if its current value is nil, then returns the initialized value. If this reference is already initialized, then storeIfNilThenLoad(_:) discards its supplied argument and returns the current value without updating it.