Skip to content

Instantly share code, notes, and snippets.

@comfly comfly/Using queues.swift
Last active Aug 31, 2016

Embed
What would you like to do?
let queue = dispatch_queue_create("QUEUE", DISPATCH_QUEUE_CONCURRENT)
var holder: Int = 10
func readSafe() -> Int {
var read: Int!
dispatch_sync(queue) {
read = holder
}
return read
}
func writeSafe(value: Int) {
dispatch_barrier_async(queue) {
holder = value
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.