DispatchedValue
public class DispatchedValue<T> : DispatchedValueWrapper
Thread-safe value wrapper, using dispatch queues to achieve synchronization.
Note
This class is not KVO-compliant. If you need this, please use subclasses of DispatchedValue.
See also
DispatchedValueWrapper
-
The wrapped value type.
Declaration
Swift
public typealias ValueType = T -
Initializes a dispatched value object.
This initializer will use the main queue for synchronization.
Declaration
Swift
public required convenience init(value: T)Parameters
valueThe initial value.
-
Initializes a dispatched value object.
Declaration
Swift
public required init(value: T, queue: DispatchQueue)Parameters
valueThe initial value.
queueThe queue to use to achieve synchronization.
-
Atomically gets the wrapped value.
The getter will be executed on the queue specified in the initialzer.
Declaration
Swift
public func get() -> TReturn Value
The actual value.
-
Atomically sets the wrapped value.
The setter will be executed on the queue specified in the initialzer.
Declaration
Swift
public func set(_ value: T)Parameters
valueThe value to set.
-
Atomically executes a closure on the wrapped value.
The closure will be passed the actual value of the wrapped value, and is guaranteed to be executed atomically, on the queue specified in the initialzer.
Declaration
Swift
public func execute(closure: (T) -> Void)Parameters
closureThe close to execute.
-
Atomically executes a closure on the wrapped value, returning some value.
The closure will be passed the actual value of the wrapped value, and is guaranteed to be executed atomically, on the queue specified in the initialzer.
Declaration
Swift
public func execute<R>(closure: (T) -> R) -> RParameters
closureThe close to execute, returning some value.
Return Value
The value returned by executing the closure.
DispatchedValue Class Reference