Concurrency and Parallelism in Swift

When I first started learning Objective-C, I already had a good understanding of concurrency and multitasking with my background in other languages, such as C and Java. This background made it very easy for me to create multithreaded applications using threads. Then, Apple changed everything when they released Grand Central Dispatch (GCD) with OS X 10.6 and iOS 4. At first, I went into denial; there was no way GCD could manage my application's threads better than I could. Then I entered the anger phase; GCD was hard to use and understand. Next was the bargaining phase; maybe I can use GCD with my threading code, so I could still control how the threading worked. Then there was the depression phase; maybe GCD does handle threading better than I could. Finally, I entered the wow phase; this GCD thing is really easy to use and works amazingly well. After using GCD and operation queues with Objective-C, I do not see a reason for using manual threads with Swift.

In this chapter, we will learn the following topics:

  • What are basics of concurrency and parallelism?
  • How to use GCD to create and manage concurrent dispatch queues?
  • How to use GCD to create and manage serial dispatch queues?
  • How to use various GCD functions to add tasks to the dispatch queues?
  • How to use Operation and OperationQueues to add concurrency to our applications?
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset