Date post: | 11-Apr-2017 |
Category: |
Technology |
Upload: | sam-mejlumyan |
View: | 46 times |
Download: | 0 times |
Concurrent Programming
Sam Mejlumyan
What really happened on Mars?July 4th, 1997
What about we’ll talk
• What is Concurrent Programming
• Concurrency APIs on iOS
• Challenges of Concurrent Programming
Concurrent vs. Parallel
Concurrency APIs on iOS
• Threads
• GCD
• Operation Queues
• Run Loops
Threads
• POSIX thread API
• The basic for GCD and Operation queues
• Objective-C wrapper – NSThread
Pthreads• Thread management - creating, joining threads
• Mutexes
• Condition variables
• Synchronization between threads using read/write locks and barriers
• Use when create application for different platform
Objective-C wrapper around pthreads
NSThread
GCD
• Low-Level API
• You don’t interact with threads directly
• Five different queues
GCD
GCD
Quality of Service• userInteractive
• userInitiated
• default
• utility
• background
• unspecified ••
Operation Queue features
• maxConcurrentOperationCount property
• sorting of operations
• specify dependencies between operations
• cancelation mechanism
• KVO
• state of operation
Sharing of ResourcesRace condition
Mutual Exclusion
Dead Locks
Priority Inversion
Conclusion
• pull out the data on the main thread
• use an operation queue to do the actual work in the background
• finally get back onto the main queue