Concurrency
Barrier and reader-writer
In this cache built on a GCD concurrent queue, which statement about the role of the .barrier flag is correct?
let q = DispatchQueue(label: "cache", attributes: .concurrent)
func read(_ k: String) -> Data? { q.sync { store[k] } }
func write(_ k: String, _ v: Data) {
q.async(flags: .barrier) { store[k] = v }
}Pick one