Concurrency by Tutorials Flashcards
What is concurrency?
the decomposability property of a program, algorithm, or problem into order-independent units
Why use concurrency?
Critical to ensure that your app runs smoothly as possible and that the end user is not ever forced to wait.
What are 2 ways to use concurrency in iOS?
- Grand Central Dispatch
2. Operation class
What is the purpose of GCD?
Queue up tasks - method or closure - that can be run in parallel.
What is a synchronous task?
Your app will wait and block the current run loop until execution finishes before moving to the next task
What is an asynchronous task?
App will start the task but return execution to your app immediately
What is a serial queue?
Only have a single thread associated with them and thus only a single task can be executed at a given time
What is a concurrent queue?
Utilize as many threads as the system has resources for
What are some advantages of splitting your app into multiple threads?
- Faster execution
- Responsiveness
- Optimized resource consumption
How do you create a serial dispatch queue in swift?
let queue = DispatchQueue(label: “”)
Are dispatch queues concurrent or serial by default?
Serial
How do you create a global QoS concurrent queue?
let queue = DispatchQueue.global(qos: .userInteractive)
How do you create a concurrent dispatch queue in swift?
let queue = DispatchQueue(label: “”, attributes: .concurrent)
List the 6 quality of services classes for global concurrent queues Apple offers? (highest to lowest priority)
1) .userInteractive
2) .userInitiatted
3) .utility
4) .background
5) .default
6) .unspecified
How to create your own concurrent queue with utility QoS?
let queue = DispatchQueue(label: “”, qos; .utility, attributes: .concurrent)