Atomic

@propertyWrapper
open class Atomic<Value>

A property wrapper type that can guarantee that it can be safely read and written from different threads/queues.

  • Creates an atomic with an initial wrapped value.

    Declaration

    Swift

    public init(wrappedValue: Value, queue: DispatchQueue? = nil)

    Parameters

    wrappedValue

    An initial value.

    queue

    A queue to confined on atomic operations. Can be nil.

  • The underlying value referenced by the atomic.

    Declaration

    Swift

    open var wrappedValue: Value { get set }
  • A projection of the atomic value that returns a atomic.

    Declaration

    Swift

    open var projectedValue: Atomic<Value> { get }
  • Asynchronously performs a given block atomically.

    Declaration

    Swift

    open func perform(_ block: @escaping (inout Value) -> Void)

    Parameters

    block

    The block to perform.