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
value
The default value for the wrapped type.
-
Atomically gets the value of the wrapped type.
Declaration
Swift
func get() -> ValueType
Return Value
The actual value of the wrapped type.
-
Atomically sets the value of the wrapped type.
Declaration
Swift
func set(_ value: ValueType)
Parameters
value
The 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
closure
The 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) -> R
Parameters
closure
The closure to execute.
Return Value
The closure’s return value.