LockingValue
public class LockingValue< T, L >: ThreadSafeValueWrapper where L: NSLocking
Represents a thread-safe value wrapper, using locking to achieve
synchronization.
Note that this class is not KVO-compliant.
If you need this, please use subclasses of DispatchedValue
.
Seealso
DispatchedValue
Seealso
ThreadSafeValueWrapper
-
The wrapped value type.
Declaration
Swift
public typealias ValueType = T
-
Initializes a locking value object.
Declaration
Swift
public required init( value: ValueType, lock: NSLocking )
-
Initializes a locking value object.
Declaration
Swift
public required convenience init( value: ValueType )
-
Atomically gets the wrapped value.
Declaration
Swift
public func get() -> ValueType
Return Value
The actual value.
-
Atomically sets the wrapped value.
-parameter value: The value to set.
Declaration
Swift
public func set( _ value: ValueType )
-
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.-parameter closure: The close to execute.
Declaration
Swift
public func execute( closure: ( ValueType ) -> 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.-parameter closure: The close to execute, returning some value.
Declaration
Swift
public func execute< R >( closure: ( ValueType ) -> R ) -> R