Find why this wrapper does not make increment() atomic.
swift
@propertyWrapper
final class Atomic<Value> {
private var value: Value
private let lock = NSLock()
var wrappedValue: Value {
get { lock.withLock { value } }
set { lock.withLock { value = newValue } }
}
init(wrappedValue: Value) { value = wrappedValue }
}
final class Counter {
@Atomic var count = 0
func increment() {
count += 1
}
}