Great answer from @mbrandonw about the challenges of locking properties. Definitely a pattern I’m seeing a lot lately.
https://forums.swift.org/t/preventing-regressions-when-conforming-to-sendable-with-unchecked/62137/4
Preventing regressions when conforming to `Sendable` with `@unchecked`
Hi @josephduffy, unfortunately writing a truly concurrency safe class is a bit harder than just locking each property. The class you have shared is "safe" to use from multiple threads in that it won't lead to data corruption, but it is not safe in the sense that it is free from race conditions. For example, a simple test where we increment a CustomClass object 10,000 times will fail: @Test func raceCondition() async { let object = CustomClass() await withTaskGroup(of: Void.self) { group in ...