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
More Decks by ohayoukenchan
See All by ohayoukenchan
iOSDC2021 知られざる課金ステータス
ohayoukenchan
1
8.4k
iOSDC2018_ohayou_kenchan.pdf
ohayoukenchan
4
4.4k
Other Decks in Programming
See All in Programming
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
410
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
320
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
120
JRuby: Past, Present, and Future
headius
0
210
Agents on Rails - Rails at Scale 2026
irinanazarova
0
300
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
160
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
580
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
190
アクセシビリティから考える情報設計
high_g_engineer
0
430
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
400
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
5.2k
Featured
See All Featured
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
510
How GitHub (no longer) Works
holman
316
150k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
250
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
Documentation Writing (for coders)
carmenintech
77
5.5k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.3k
GraphQLとの向き合い方2022年版
quramy
50
15k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
490
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.8k
Making the Leap to Tech Lead
cromwellryan
135
10k
The Limits of Empathy - UXLibs8
cassininazir
1
690
Optimising Largest Contentful Paint
csswizardry
37
4k
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)は、マルチスレッド ・プログラム実装上の問題