Queues
Dispatch queues are GCD’s fundamental structure. A queue is a list of work items. A queue, by definition, is drained in a FIFO manner – first in, first out order. GCD maintains a thread pool where it actually runs the work items that are pulled from queues. Work items can be submitted as a block or a function pointer/context pair. Each serial queue is backed by a global queue.
There are two kinds of queues, serial queues and global queues. Serial queues dispatch their work items and complete them in FIFO order. Serial queues will not have two different work items executing simultaneously. This is what serializes access to sensitive data structures. The main queue, the queue for doing work on the main thread, is a serial queue.
A global ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access