Instance Methodpointfreeco.swift-concurrency-extras 1.3.1ConcurrencyExtras
withValue(_:)
Perform an operation with isolated access to the underlying value.
This declaration is deprecated: Use 'LockIsolated' instead.
func withValue<T>(_ operation: (inout Value) throws -> T) rethrows -> T
Parameters
- operation
An operation to be performed on the actor with the underlying value.
Returns
The result of the operation.
Useful for modifying a value in a single transaction.
// Isolate an integer for concurrent read/write access:
let count = ActorIsolated(0)
func increment() async {
// Safely increment it:
await self.count.withValue { $0 += 1 }
}