I'm going through a Ray Wenderlich tutorial that says that dispatching synchronously onto the current queue will cause a deadlock. I'm not able to see how and why that is. Would someone explain this to me?
You can think of
dispatch_sync
and being composed of two operations:
An async dispatch of the block to the queue.
A wait for that block to finish.
If you
dispatch_sync
to the current queue then you deadlock because:
The block won’t run because the current queue is busy running your code.
Your code will never complete because it’s waiting for the block to run.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"