So I'm trying to use GCD in the CLI. To test it out i wrote some code like this:
import Foundation
var i = 0
print("a: ",i)
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0)) {
for n in 1..<10{
i++
}
print("c: ",i)
dispatch_async(dispatch_get_main_queue()){
print("d: ",i)
}
}
print("b: ",i)
sleep(5)
print("e: ",i)
the output of this is: a: 0 b: 0 c: 9 e: 9
with the last line printing a few seconds later. What I'm trying to find out is what happened at d? Nothing I put in that block seems to execute. This works fine when I use it in iOS, just not in the CLI.