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
protect_mutable_state_in_concurrent_Swift_appli...
Search
ohayoukenchan
June 25, 2021
Programming
1.5k
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
Transcript
37 slides
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)は、マルチスレッド ・プログラム実装上の問題
More Decks by ohayoukenchan
See All by ohayoukenchan
iOSDC2021 知られざる課金ステータス
ohayoukenchan
1
8.5k
iOSDC2018_ohayou_kenchan.pdf
ohayoukenchan
4
4.5k
Other Decks in Programming
See All in Programming
Proxmox x Talos Linux x Terraform で実現するなんかいい感じの Kubernetes クラスタ / A Sleek Kubernetes Cluster Powered by Proxmox, Talos Linux, and Terraform
nnaka2992
0
260
疎結合とは何か?ソフトウェア設計における結合バランスについて考える #phpcon_niigata
kajitack
2
340
はじめてのPLATEAU
nokonoko1203
1
660
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
210
なぜ私たちは「現時点では」KMPの導入を見送ったのか
chigichan24
1
310
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
190
将来の標準フォーマッター?ktfmtを深堀る
t45k
0
220
小さなアプリを作って公開するまで
onozaty
0
200
Goコンパイラを作ってGoをもっと理解する / Build a Go compiler to better understand Go
ikura_hamu
0
130
AIが実装を担う時代の「技術設計」と「チームマネジメント」
kamina_zzz
2
280
flutter_test のその先へ — Flutter アプリの LLM 機能に「評価」という品質保証を
kosukesaigusa
0
200
プロジェクトコードをキレイキレイしよう!暗黙的な参照を読み解く静的解析
ostk0069
0
220
Featured
See All Featured
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
400
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
550
Documentation Writing (for coders)
carmenintech
77
5.6k
Leo the Paperboy
mayatellez
11
2.5k
We Have a Design System, Now What?
morganepeng
55
8.4k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Side Projects
sachag
456
43k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.9k
Designing for Performance
lara
612
70k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7.1k
Raft: Consensus for Rubyists
vanstee
143
7.9k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
620