4
Concurrency in Swift
WHAT'S IN THIS CHAPTER?
- Understanding concurrent programming
- Understanding the process architecture on OS X and iOS
- Designing concurrent programs
- Using asynchronous methods and functions
- Creating timers and threads
- Writing programs with Grand Central Dispatch
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
You can find the wrox.com downloads for this chapter at http://www.wrox.com/go/proswift on the Download Code tab. The code for this chapter is contained in the following files:
- async.swift
- threads.swift
- timers.swift
- gcd.swift
Concurrency is the process by which a computer or individual program can perform multiple tasks simultaneously, including executing tasks or processes in the background. Modern computers have many programs running at the same time. Even “single task” operating systems such as iOS have many unseen programs running in the background, in addition to any user-facing programs that may be open. Each individual programs can run multiple actions at the same time. It is difficult and constraining to design and write iOS and OS X programs without an understanding of the concurrency primitives used by both operating systems.
This chapter introduces you to the foundations for concurrency programming used by OS X and iOS: classes such as NSTimer and NSThread, as well as libraries like Grand Central Dispatch. It also discusses the importance of concurrency, particularly in the use of asynchronous methods, in modern applications. By the end of the chapter, ...
Get Professional Swift now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.