Grand Central Dispatch

  • GCD schedules blocks for run-time execution by placing them on a dispatch queue.
  • When it removes a block from a queue, it assigns the block to an available thread from the thread pool it manages.
  • GCD identifies two types of dispatch queues: serial and concurrent.
  • Internally, GCD’s thread pool is composed of POSIX threads.

Serial Queue

  • Blocks placed on a serial queue are removed in FIFO order
  • Once a block has been removed from the queue, it must complete execution before another block is removed.
  • Each process has its own serial queue (known as its main queue).
  • Developers can create additional serial queues that are local to particular processes.
  • Serial queues are useful for ensuring the sequential execution of several tasks.

Concurrent Queue

  • Blocks placed on a concurrent queue are also removed in FIFO order, but several blocks may be removed at a time, thus allowing multiple blocks to execute in parallel.
  • There are three system-wide concurrent dispatch queues, and they are distinguished according to priority: low, default, and high.
  • Priorities represent an approximation of the relative importance of blocks.

results matching ""

    No results matching ""