Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
360|iDev Concurrency Workshop
Search
sammyd
August 21, 2016
Programming
340
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
360|iDev Concurrency Workshop
Slides accompanying the 360|iDev concurrency workshop from 2016
sammyd
August 21, 2016
More Decks by sammyd
See All by sammyd
Core Image: Great when it works
sammyd
1
580
iOS Views & Animations: Learning by stealing
sammyd
1
220
Machine Learning on Mobile—a primer
sammyd
0
150
Core ML: A whistlestop tour
sammyd
1
210
DIY DI
sammyd
2
150
iOSConfSG 2017: Decoding Codable
sammyd
3
220
Machine Learning: deciphering the hype
sammyd
0
190
Notify Me, Notify You. Aha!
sammyd
1
220
SwiftConf 2016: Concurrency on iOS
sammyd
1
230
Other Decks in Programming
See All in Programming
React Native経験者が Flutterを30⽇間触って驚いたこと
3saito
0
170
私なりのハーネスエンジニアリング ~独自の言語処理系の開発を通して~
seosoft
0
200
조합이폭발하는디자인시스템이걸눈으로도테스트하라고요
giljongyu
0
740
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
160
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
330
protojson における文字化けの扱い
kazuki1023
0
220
Kotlinize Is Not Just Converting to Kotlin
chigichan24
1
220
SODA - FACT BOOK(EN)
sodainc
1
220
flutter_test のその先へ — Flutter アプリの LLM 機能に「評価」という品質保証を
kosukesaigusa
0
200
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
220
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
110
LLM 101
dalinaum
0
470
Featured
See All Featured
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.3k
Ethics towards AI in product and experience design
skipperchong
2
460
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
320
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.2k
Google's AI Overviews - The New Search
badams
0
1.7k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
630
Designing Experiences People Love
moore
143
24k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
Into the Great Unknown - MozCon
thekraken
41
2.8k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
Agile that works and the tools we love
rasmusluckow
331
22k
Crafting Experiences
bethany
1
430
Transcript
Concurrency workshop Sam Davies @iwantmyrealname _ github.com/sammyd git.io/v6waD
concurrency is hard
what is concurrency?
why use concurrency?
common concurrency problems
race condition
Race Condition time Value 1 Thread 1 Thread 2 inc
Race Condition time Value 1 1 Thread 1 Thread 2
inc r1
Race Condition time Value 1 1 1 Thread 1 Thread
2 inc r1 +1
Race Condition time Value 1 1 1 2 Thread 1
Thread 2 inc r1 w2 +1
Race Condition time Value 1 1 1 2 2 Thread
1 Thread 2 inc r1 w2 +1 inc
Race Condition time Value 1 1 1 2 2 2
Thread 1 Thread 2 inc r1 w2 +1 inc r2
Race Condition time Value 1 1 1 2 2 2
2 Thread 1 Thread 2 inc r1 w2 +1 inc r2 +1
Race Condition time Value 1 1 1 2 2 2
2 3 Thread 1 Thread 2 inc r1 w2 +1 inc r2 w3 +1
Race Condition time Value 1 Thread 1 Thread 2 inc
Race Condition time Value 1 1 Thread 1 Thread 2
inc r1 inc
Race Condition time Value 1 1 1 Thread 1 Thread
2 inc r1 inc r1
Race Condition time Value 1 1 1 1 Thread 1
Thread 2 inc r1 inc r1 +1
Race Condition time Value 1 1 1 2 1 Thread
1 Thread 2 inc r1 inc r1 w2 +1
Race Condition time Value 1 1 1 2 1 2
Thread 1 Thread 2 inc r1 +1 inc r1 w2 +1
Race Condition time Value 1 1 1 2 1 2
2 Thread 1 Thread 2 inc r1 w2 +1 inc r1 w2 +1
priority inversion
Priority Inversion time low priority resource
Priority Inversion time low priority resource
Priority Inversion time low medium priority resource
Priority Inversion time low medium high priority resource
Priority Inversion time low medium high priority resource
Priority Inversion time low medium high priority resource
Priority Inversion time low medium high priority resource
deadlock
Deadlock time resource1 resource2 Thread 1 Thread 2
Deadlock time resource1 resource2 Thread 1 Thread 2
Deadlock time resource1 resource2 Thread 1 Thread 2
Deadlock time resource1 resource2 Thread 1 Thread 2
Deadlock time resource1 resource2 Thread 1 Thread 2
Deadlock time resource1 resource2 Thread 1 Thread 2
Deadlock time resource1 resource2 Thread 1 Thread 2
Deadlock time resource1 resource2 Thread 1 Thread 2
$&'( queueueueueue paradigm
Tasks & Queues Thread 1 Thread 2 Queue
Tasks & Queues Thread 1 Thread 2 Queue
Tasks & Queues Thread 1 Thread 2 Queue
Tasks & Queues Thread 1 Thread 2 Queue
Tasks & Queues Thread 1 Thread 2 Queue
Tasks & Queues Thread 1 Thread 2 Queue
Tasks & Queues Thread 1 Thread 2 Queue
feeling brave?
a touch more theory
Thread Safety time Value 1111 Thread 1 Thread 2 Thread
3
Thread Safety time Value 1111 Thread 1 Thread 2 r1111
Thread 3
Thread Safety time Value 1111 1112 Thread 1 Thread 2
r1111 w2222 Thread 3
Thread Safety time Value 1111 1112 1122 Thread 1 Thread
2 r1111 w2222 r1122 Thread 3
Thread Safety time Value 1111 1112 1122 1223 Thread 1
Thread 2 r1111 w2222 r1122 w3333 Thread 3 r1223
Thread Safety time Value 1111 1112 1122 1223 2233 Thread
1 Thread 2 r1111 w2222 r1122 w3333 Thread 3 r1223
Thread Safety time Value 1111 1112 1122 1223 2233 2333
Thread 1 Thread 2 r1111 w2222 r1122 r2333 w3333 Thread 3 r1223
Thread Safety time Value 1111 1112 1122 1223 2233 2333
3333 Thread 1 Thread 2 r1111 w2222 r1122 r2333 w3333 Thread 3 r1223
Thread Safety time Value 1111 1112 1122 1223 2233 2333
3333 3333 3333 Thread 1 Thread 2 r1111 w2222 r1122 r2333 w3333 Thread 3 r1223 r3333 r3333
Dispatch Barrier time task task task task task barrier task
task task task task task task task
Dispatch Barrier time read read read read read read write
read read read read read read
alternatives to
promises networkRequest(url, callback: { data in decompressor(data, callback: { image
in imageResizer(image, callback: { small in filterImage(small, callback: { filtered in displayImage(filtered) }) }) }) })
promises promise<int> int error
promises str
promises promise<img> str f
promises promise<img> str error f img
promises promise<img> str error f img error handler
promises promise<img> str error f img g promise<img> error handler
promises promise<img> str error f img g promise<img> error error
handler img
promises promise<img> str error f img g promise<img> error error
handler img
promises networkRequest(url) .then(decompressor) .then(imageResizer) .then({ (image) in return filterImage(image) }).then(displayImage)
.catch({ (error) in print(error) })
imagine the “promise pipeline” accepted a sequence of values…
that’s reactive programming
conclusion
concurrency is hard
you will get it wrong
• raywenderlich.com/videos • git.io/v6waD • @iwantmyrealname