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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ohayoukenchan
June 25, 2021
Programming
1.4k
0
Share
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
Sans tests, vos agents ne sont pas fiables
nabondance
0
120
Kubernetesを使わない環境にもCloud Nativeなデプロイを実現する / Enabling Cloud Native deployments without the complexity of Kubernetes
linyows
3
400
なぜあなたのコードには「コシ」がないのか?〜AI時代に問う、最後まで美味しい設計と戦略〜 #phpconkagawa / phpconkagawa2026
shogogg
0
210
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
350
Cloudflare で始める Data Platform
ta93abe
0
160
PHPer、Cloudflare に引っ越す
suguruooki
2
210
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
180
GitHubCopilotCLIをはじめよう.pdf
htkym
0
330
Programming with a DJ Controller — not vibe coding
m_seki
3
860
「OSSがあるなら自作するな」は AI時代も正しいか ── Build vs Adopt の新しい判断基準
kumorn5s
7
2.7k
Firefoxにコントリビューションして得られた学び
ken7253
2
160
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
160
Featured
See All Featured
Marketing to machines
jonoalderson
1
5.3k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.4k
Optimizing for Happiness
mojombo
378
71k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
340
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
How to Think Like a Performance Engineer
csswizardry
28
2.6k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
800
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
530
Context Engineering - Making Every Token Count
addyosmani
9
890
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
The agentic SEO stack - context over prompts
schlessera
0
780
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
240
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)は、マルチスレッド ・プログラム実装上の問題