Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
protect_mutable_state_in_concurrent_Swift_appli...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
ohayoukenchan
June 25, 2021
Programming
1.4k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
protect_mutable_state_in_concurrent_Swift_applications.pdf
ohayoukenchan
June 25, 2021
More Decks by ohayoukenchan
See All by ohayoukenchan
iOSDC2021 知られざる課金ステータス
ohayoukenchan
1
8.3k
iOSDC2018_ohayou_kenchan.pdf
ohayoukenchan
4
4.4k
Other Decks in Programming
See All in Programming
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
180
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
440
GitHub Copilot CLIのいいところ
htkym
2
1.3k
AI駆動開発勉強会 広島支部 第一回勉強会 AI駆動開発概要とワークショップ
hayatoshimiu
0
450
dRuby over BLE
makicamel
2
320
AIエージェントの隔離技術の徹底比較
kawayu
0
470
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
190
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
160
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
600
Claspは野良GASの夢をみるか
takter00
0
170
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
110
OSもどきOS
arkw
0
470
Featured
See All Featured
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
WENDY [Excerpt]
tessaabrams
11
38k
A Tale of Four Properties
chriscoyier
163
24k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
44k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
320
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.8k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Code Review Best Practice
trishagee
74
20k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
160
4 Signs Your Business is Dying
shpigford
187
22k
Transcript
protect mutable state in concurrent Swift applications sento_kun (ohayoukenchan) ママリiOSエンジニア募集中だよ
この話の流れ - data races - actors in Swift(Actorってなぁに) - actor
reentrancy(再入性) - actor isolation(Actorの分離) - main actor(メインスレッドでの非同期処理)
いきなりですが Data Races とは?
None
共有された 可変型の状態が必要 とされる場合がある
共有された可変型の状態 をうまく同期させたい
actors in Swift
Actors - Actorsは独自の状態を持ち、その状態は他のプログラムから隔離されて います。 - Actorsにアクセスするには、Actorsを経由するしかありません。 - Actorsを経由するときはいつでも、Actorsの同期メカニズムによって、他の コードが同時にActorsの状態にアクセスしないことが保証されます。 -
ロックやシリアルディスパッチキューを手動で使用したときに得られるのと 同じ相互排除特性が得られます
Data Races データ競合(data race)は、マルチスレッド ・プログラム実装上の問題
One will get there first, and the other will have
to wait its turn.
actors in Swift
Actor reentrancy
actors in Swift
None
Actor Isolation
protocol conformances
Await
Await
None
None
Closures
None
None
actor isolation and data
None
None
Sendable
None
None
None
Main Actor
thinking about main thread
None
None
まとめもりー - mutableな状態への同時アクセスを防ぐことでデータ競合を防ぐ - value semantic(letとかstruct)みたいなimmutableなデータと Actors(mutable な状態への同時アクセスできる)を使って非同期処理 を設計しよう -
Actorの分離(内側にあるか外側にあるか)を考慮する - メインスレッドで非同期処理をすることを保証するため DispatchQueue.mainのかわりにMainActorを使う
おわり
Data Races データ競合(data race)は、マルチスレッド ・プログラム実装上の問題