Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created January 28, 2024 08:13
Show Gist options
  • Save laevandus/8d32c8a535180098c3b8f98ad3fb954d to your computer and use it in GitHub Desktop.
Save laevandus/8d32c8a535180098c3b8f98ad3fb954d to your computer and use it in GitHub Desktop.
func store(_ data: Data, forIdentifier id: String) {
// Incorrect because read and write happen in separate blocks on the queue
// contents[id] = data
// Correct
queue.async(flags: .barrier) {
self._contents[id] = data
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment