Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
5 分でやる Rust Concurrency in Action
Search
Ryo Okubo
June 27, 2017
Programming
1
470
5 分でやる Rust Concurrency in Action
RustのLT会! Rust入門者の集い #3 で話した資料です。
https://rust.connpass.com/event/56276/
Ryo Okubo
June 27, 2017
Tweet
Share
More Decks by Ryo Okubo
See All by Ryo Okubo
UbieのAIパートナーを支えるコンテキストエンジニアリング実践
syucream
3
1.3k
メルカリ・メルペイの成長を支える データ基盤とはどんなものか
syucream
7
7.2k
バッチとストリーミング、それぞれの障害に立ち向かう
syucream
3
3.8k
How Scala works at Mercari
syucream
2
1.1k
Production-ready stream data pipeline in Merpay, Inc
syucream
2
13k
データとML周辺エンジニアリン グを考える会 #2 イントロ
syucream
0
650
マイクロサービスにおける ログ収集の課題と取り組み
syucream
7
2.8k
Stream Data Pipeline for Microservices in Merpay
syucream
6
1.3k
メルペイにおける、マイクロサービスに寄り添うログ収集基盤 / Microservices-frendly Data Pipeline
syucream
0
18k
Other Decks in Programming
See All in Programming
MAP, Jigsaw, Code Golf 振り返り会 by 関東Kaggler会|Jigsaw 15th Solution
hasibirok0
0
250
20251212 AI 時代的 Legacy Code 營救術 2025 WebConf
mouson
0
190
AIエンジニアリングのご紹介 / Introduction to AI Engineering
rkaga
8
3.1k
著者と進める!『AIと個人開発したくなったらまずCursorで要件定義だ!』
yasunacoffee
0
150
Graviton と Nitro と私
maroon1st
0
110
AIコーディングエージェント(Manus)
kondai24
0
200
TUIライブラリつくってみた / i-just-make-TUI-library
kazto
1
400
開発に寄りそう自動テストの実現
goyoki
2
1.2k
從冷知識到漏洞,你不懂的 Web,駭客懂 - Huli @ WebConf Taiwan 2025
aszx87410
2
2.8k
Rediscover the Console - SymfonyCon Amsterdam 2025
chalasr
2
180
FluorTracer / RayTracingCamp11
kugimasa
0
240
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
120
Featured
See All Featured
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
670
Side Projects
sachag
455
43k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
0
91
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
500
Ruling the World: When Life Gets Gamed
codingconduct
0
92
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
84
First, design no harm
axbom
PRO
1
1k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
2
250
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
400
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
83
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
110
Transcript
5 分でやる Rust Concurrency in Ac0on @syu_cream
わたしはだれ • @syu_cream – ウェッブサービスの裏側を支える技術者 – 趣味でmrubyの薄い本やC++のコード書いてます
今日のお話 • Rust でマルチスレッドプログラミングするのって • C++ でやるより楽だよねというはなし • 時間も限られてるし mutex
についてのみ • 題材としてスレッド毎にvectorに要素追加してみる – GitHub に今日話すソースコードあります – h<ps://github.com/syucream/rust_cia
C++ で書く場合(データ競合起こす版) • コンパイルは通る – ただし未定義動作になる
C++ で書く場合 • ロックを取ることでデータ競合を避ける
Rust で書く場合(データ競合起こす版1) • コンパイルが…
Rust で書く場合(データ競合起こす版1) • コンパイルが…通らない! – 複数のスレッドに変数をborrowしようとしてるため
Rust で書く場合(データ競合起こす版2) • じゃあ Arc で参照をcloneしてborrowしよう! • これでコンパイルが…
Rust で書く場合(データ競合起こす版2) • じゃあ Arc で参照をcloneしてborrowしよう! • これでコンパイルが…通らない! – Arc<T> の変数は複数スレッドから変更できない
Rust で書く場合 • Mutex<T> を使う! – lock() でロックを取って変更する
マルチスレッドプログラミングにおける C++ vs Rust • C++ – C++11以降ならthread,mutexが標準で使えて便利 – データ競合についてはプログラマが気をつける必要あり
• Rust – データ競合が起こる場合コンパイル時にエラーになる
Rustでも競合状態は避けきれない • 以下のコードはデッドロックを起こす…
まとめ • Rust でマルチスレッドプログラミングするのって – コンパイル時のチェックが手厚いので • C++ でやるより楽だよねというはなし –
ただし万能なわけではないよ