pointfreeco / swift-concurrency-extras

Useful, testable Swift concurrency.
MIT License
343 stars 23 forks source link

`LockIsolated.withValue` closure should be sendable #13

Closed stephencelis closed 1 year ago

stephencelis commented 1 year ago

Brought up by @kabiroberai in Slack with this demo of the issue:

class Bad {
  var i = 0
  func racy() { i += 1 }
}

let bad = LockIsolated(Bad())

var _bad: Bad?
bad.withValue { _bad = $0 }
_bad?.racy()  // not lock-isolated!