Skip to content

Instantly share code, notes, and snippets.

@rnapier
Forked from beccadax/dispatch-sync-safe.swift
Created June 13, 2014 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rnapier/6d3b3a3a33f3d4bab19b to your computer and use it in GitHub Desktop.
Save rnapier/6d3b3a3a33f3d4bab19b to your computer and use it in GitHub Desktop.
func dispatch_sync<R> (queue: dispatch_queue_t, block: Void -> R ) -> R {
var result: R!
dispatch_sync(queue) {
result = block()
}
return result
}
func result() -> String {
return
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
return "something"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment