DispatchedValue
public class DispatchedValue< T >: DispatchedValueWrapper
Thread-safe value wrapper, using dispatch queues to achieve synchronization.
Note that this class is not KVO-compliant.
If you need this, please use subclasses of DispatchedValue
.
Seealso
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 )
-
Initializes a dispatched value object.
Declaration
Swift
public required init( value: T, queue: DispatchQueue )
-
Atomically gets the wrapped value.
The getter will be executed on the queue specified in the initialzer.Declaration
Swift
public func get() -> T
Return Value
The actual value.
-
Atomically sets the wrapped value.
The setter will be executed on the queue specified in the initialzer.-parameter value: The value to set.
Declaration
Swift
public func set( _ value: T )
-
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.-parameter closure: The close to execute.
Declaration
Swift
public func execute( closure: ( T ) -> Swift.Void )
-
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.-parameter closure: The close to execute, returning some value.
Declaration
Swift
public func execute< R >( closure: ( T ) -> R ) -> R