Skip to content

Instantly share code, notes, and snippets.

@misbell
Created October 4, 2016 21: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 misbell/97f3c840a570598270fa8e406a7c60c8 to your computer and use it in GitHub Desktop.
Save misbell/97f3c840a570598270fa8e406a7c60c8 to your computer and use it in GitHub Desktop.
Returning value from subsystem with DispatchQueue.sync - Swift 3.0 - October 4 2016
// pretending this is a subsystem
let holdval = HoldAValue()
var avalue: Int {
var i: Int = 0
DispatchQueue.global(qos: .userInitiated).sync {
i = holdval.anIntValue
}
return i
}
print ("\(avalue) avalue")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment