Reputation: 29314
I'm very confused what serial vs concurrent queues are. Does concurrent allow a bunch of operations to be in the queue, and then split them up over available threads, while serial does the same, but limiting it to one thread and waiting for one at a time to finish?
The explanations in the documentation seem very confusing.
Upvotes: 0
Views: 262
Reputation: 342
Queues: Must be serial or concurrent. As well as global or private at the same time.
Serial queues: tasks will be finished one by one
Concurrent queues: tasks will be performed simultaneously and will be finished on unexpected schedules
Private queues: can be both serial or concurrent
Global queues:
Queue can be performed synchronously or asynchronously , but this will effect on parent queue not on queue it self
So:
Synchronous function returns control to the parent queue only after the task is finished. It blocks the queue and waits until the task is finished.
Asynchronous function returns control to the parent queue right after task has been sent to be performed on the different queue. It doesn't wait until the task is finished. It doesn't block the parent queue.
Upvotes: 0
Reputation: 539775
"serial" means that the blocks submitted to the queue are executed sequentially, i.e. the second block is not executed before the first one has finished. It does not mean that the blocks are executed on the same thread.
"concurrent" means that the blocks submitted to the queue may execute concurrently (on different threads).
In both cases, GCD uses a "thread pool" to execute blocks, so you cannot know on which thread a block will be executed. The only exception is the "main queue" which executes all blocks on the main thread.
Upvotes: 4
Reputation: 80265
Concurrent (1.) queues:
------
------
Serial (6.) queues:
-------
-------
Upvotes: 2