UnsafeAtomicLazyReference
An unsafe reference type holding a lazily initializable atomic strong reference, requiring manual memory management of the underlying storage representation.
@frozen struct UnsafeAtomicLazyReference<Instance> where Instance : AnyObjectThese values can be set (initialized) exactly once, but read many times.
Related Types
typealias ValueThe value logically stored in an atomic lazy reference value.
Initializers
init(at: UnsafeMutablePointer<UnsafeAtomicLazyReference<Instance>.Storage>) Initialize an unsafe atomic lazy reference that uses the supplied memory location for storage. The storage location must already be initialized to represent a valid atomic value.
Shorthand Methods for Dynamically Allocating Storage
static func create() -> UnsafeAtomicLazyReference<Instance> Create a new
UnsafeAtomicLazyReferencevalue by dynamically allocating storage for it.func destroy() -> UnsafeAtomicLazyReference<Instance>.Value Disposes of the current value of the storage location corresponding to this unsafe atomic lazy reference, then deinitializes and deallocates the 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.