O'Reilly logo

Pro Multithreading and Memory Management for iOS and OS X by Kazuki Sakamoto, Tomohiko Furumoto

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7

GCD Basics

In this chapter, we show how to use GCD. At first, we start with a dispatch queue that is a core concept of GCD and show how to add tasks to the queues. After that, we design an API to control queues and tasks. Finally, we also show how to dispatch I/0 to control files using GCD.

Dispatch Queues

A dispatch queue is, as its name suggests, a queue to store tasks to be executed. Application programmers can write tasks as Block literals and add them to a dispatch queue by a dispatch_async function, and the like. Then the dispatch queue executes the tasks in the added order, first-in-first-out (FIFO), as shown in Figure 7–1.

Figure 7–1. Execution on a dispatch queue

As shown in Figure 7–2, there are two kinds of dispatch ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required