I'm trying to understand the differences between the types of queues. As I understand it there are 3 types:
- Global queue - concurrent - blocks are executed as soon as possible regardless of order
- Main queue - serial - blocks are executed as they were submitted
- Private queue - serial
What I'm wondering is: What are the differences between dispatch_sync and dispatch_async when submitted to each kind of queue? This is how I understand it thus far:
dispatch_sync(global_queue)^
{
// blocks are executed one after the other in no particular order
// example: block 3 executes. when it finishes block 7 executes.
}
dispatch_async(global_queue)^
{
// blocks are executed concurrently in no particular order
// example: blocks 2,4,5,7 execute at the same time.
}
dispatch_sync(main_queue)^
{
// blocks are executed one after the other in the order they were submitted
// example: block 1 executes. when it finishes block 2 will execute and so forth.
}
dispatch_async(main_queue)^
{
// blocks are executed concurrently in the order they were submitted
// example: blocks 1-4 (or whatever amount of threads the system can handle at one time) will fire at the same time.
// when the first block completes block 5 will then execute.
}
I'd like to know how much my perception of this is correct.