Working on getting some concurrency going for my app. I have a snippet of code I'm curious about what thread it exists on.
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
// For each location, update the user location
for location in locations
locationManager is called on main thread,
dispatch_sync will cause the main thread blocked until the block finishes executing, so since the main thread will block and can't do anything, why not use the main thread to execute the block ? I think it's an optimization of GCD.
The GCD Reference says:
As an optimization, this function invokes the block on the current thread when possible.
You can't assume block you submit to dispatch_queue will execute in any threads, dispatch_queue doesn't attach to any specific threads(except for the main queue).