ReadWriteLock

public final class ReadWriteLock<T>

Many readers, single writer generic lock.

let myClass = ...
let lock = ReadWriteLock(myClass)

lock.mutate {
   // do stuff with $0 to update myClass
}

Public Properties

  • Returns the current value.

    Declaration

    Swift

    public var value: T { get }

Public Functions

  • Mutates the current value within the provided block.

    Declaration

    Swift

    public func mutate(_ block: @escaping (inout T) -> Void)

    Parameters

    block

    The mutating block

Initializers

  • Creates an instance with the provided parameters.

    Declaration

    Swift

    public init(_ value: T, label: String? = nil, qualityOfService: DispatchQoS = .utility)

    Parameters

    value

    The value to wrap

    label

    The label for the underlying queue

    queue

    The underlying queue

    Return Value

    The instance