Atomic
public final class Atomic<Value>
An atomic variable.
-
Atomically get or set the value of the variable.
Declaration
Swift
public var value: Value { get set } -
Initialize the variable with the given initial value.
Declaration
Swift
public init(_ value: Value)Parameters
valueInitial value for
self. -
Atomically modifies the variable.
Declaration
Swift
@discardableResult public func modify<Result>(_ action: (inout Value) throws -> Result) rethrows -> ResultParameters
actionA closure that takes the current value.
Return Value
The result of the action.
-
Atomically perform an arbitrary action using the current value of the variable.
Declaration
Swift
@discardableResult public func withValue<Result>(_ action: (Value) throws -> Result) rethrows -> ResultParameters
actionA closure that takes the current value.
Return Value
The result of the action.
-
Atomically replace the contents of the variable.
Declaration
Swift
@discardableResult public func swap(_ newValue: Value) -> ValueParameters
newValueA new value for the variable.
Return Value
The old value.
View on GitHub
Install in Dash
Atomic Class Reference