ThreadSafeValueWrapper
public protocol ThreadSafeValueWrapper
Protocol for AtomicKit thread-safe wrapper objects around a value/type.
-
Undocumented
Declaration
Swift
associatedtype ValueType -
Required initializer.
Initializes a thread-safe wrapper object with a default value.
Declaration
Swift
init(value: ValueType)Parameters
valueThe default value for the wrapped type.
-
Atomically gets the value of the wrapped type.
Declaration
Swift
func get() -> ValueTypeReturn Value
The actual value of the wrapped type.
-
Atomically sets the value of the wrapped type.
Declaration
Swift
func set(_ value: ValueType)Parameters
valueThe value to set for the wrapped type.
-
Atomically executes a custom closure, receiving the value of the wrapped type.
The passed closure is guaranteed to be executed atomically, in respect of the current value of the wrapped type.
Declaration
Swift
func execute(closure: (ValueType) -> Void)Parameters
closureThe closure to execute.
-
Atomically executes a custom closure, receiving the value of the wrapped type.
The passed closure is guaranteed to be executed atomically, in respect of the current value of the wrapped type.
Declaration
Swift
func execute<R>(closure: (ValueType) -> R) -> RParameters
closureThe closure to execute.
Return Value
The closure’s return value.
ThreadSafeValueWrapper Protocol Reference