setValue(_:)

Overwrite the isolated value with a new value.

LockIsolated.swift:80
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:
var count = LockIsolated(0)

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