Skip to content

Glossary

Dispatch queue

libdispatch's basic unit of serialization. Submit blocks; they run in submission order on worker threads from the kernel-managed pool.

A dispatch queue is libdispatch's basic unit of serialization. Submit a block via dispatch_async, dispatch_sync, or dispatch_after; the queue ensures blocks run in submission order, one at a time (serial) or possibly in parallel (concurrent).

dispatch_queue_t q = dispatch_queue_create("com.acme.work", DISPATCH_QUEUE_SERIAL);
dispatch_async(q, ^{ /* runs eventually */ });

Queue flavors:

  • Serial — blocks run one at a time. Used for protecting mutable state without locks.
  • Concurrent — blocks may run in parallel on multiple worker threads.
  • Global queues — one per QoS class, owned by libdispatch. Most user queues target one.
  • Main queue — the special serial queue tied to the main thread (UI updates).
apple-oss-distributions/libdispatchsrc/queue.cQueue creation, lifecycle, and the target chain.View on GitHub(line )

Blocks submitted via dispatch_async capture the calling thread's voucher, so QoS and accounting flow through async work without per-call propagation.

Underneath, queues route to the workqueue — the kernel-managed thread pool. Queues themselves are cheap; threads are not. The workqueue pool is bounded; submitting 10K blocks does not spawn 10K threads.

See also: workqueue, QoS class, and the libdispatch internals article.