-
Initializes an atomic value with an initial value.
Declaration
Swift
public init(_ value: A)Parameters
valueInitial value for this reference.
-
Gets or sets the underlying value in a thread-safe manner.
Declaration
Swift
public var value: A { get set } -
Mutates the underlying value using the provided function.
Declaration
Swift
public func mutate(_ transform: (inout A) -> ())Parameters
transformTransformation function
-
Gets the underlying value and sets a new value.
Declaration
Swift
public func getAndSet(_ newValue: A) -> AParameters
newValueNew value to be stored in this atomic reference.
Return Value
Previous value saved in this reference, before the modification.
-
Gets the underlying value and sets a new value transforming it with a function.
Declaration
Swift
public func getAndUpdate(_ f: @escaping (A) -> A) -> AParameters
fTransforming function.
Return Value
Previous value saved in this reference, before the modification.
-
Sets a new value in this atomic reference and gets the newly updated value.
Declaration
Swift
public func setAndGet(_ newValue: A) -> AParameters
newValueValue to be set in this atomic reference.
Return Value
Newly set value.
-
Sets a new value transforming the underlying one using a function and gets the new value.
Declaration
Swift
public func updateAndGet(_ f: @escaping (A) -> A) -> AParameters
fTransforming value.
Return Value
Value resulting from transforming the underlying value.
-
Sets a new value if the underlying value is nil
Declaration
Swift
@discardableResult public func setIfNil<AA>(_ newValue: AA) -> Bool where A == AA?Parameters
newValueValue to be set.
Return Value
True if the new value was set; false, otherwise.
-
Sets the underlying value to nil
Declaration
Swift
public func setNil<AA>() where A == AA?
-
Sets a new value if the underlying value is equal to the one passed as a test.
Declaration
Swift
public func compare(_ test: A, andSet newValue: A) -> BoolParameters
testValue to compare with the underlying value.
newValueValue to be set.
Return Value
True if the new value was set; false, otherwise.
Install in Dash
Atomic Class Reference