Last active
August 31, 2016 21:59
-
-
Save comfly/6a9dcf7681754017b4d1f609b10bdace to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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