I have the following code, which to my understanding should provide thread safe read and write on _predictions
. My isolationQueue is a concurrent queue and needs to stay as such. I call multiple independent async operations on this queue to calculate predictions for various images. The only shared item between the various calls is the when prediction is set.
var isolationQueue = DispatchQueue.global(qos: .default)
var _predictions: [Int:[Prediction]] = [:]
var predictions:[Int: [Prediction]] {
get {
var result: [Int: [Prediction]]!
isolationQueue.sync {
result = _predictions
}
return result
}
set(value) {
isolationQueue.sync {
self._predictions = value
}
}
}
However for some reason Thread Sanitizer seems to detect a racing condition between the getter and the setter.
Am I missing something?