setValue(_:)

Overwrite the isolated value with a new value.

ActorIsolated.swift:110

This declaration is deprecated: Use 'LockIsolated' instead.

func setValue(_ newValue: @autoclosure () throws -> Value) rethrows

Parameters

newValue

The value to replace the current isolated value with.

// Isolate an integer for concurrent read/write access:
let count = ActorIsolated(0)

func reset() async {
  // Reset it:
  await self.count.setValue(0)
}