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
5 分でやる Rust Concurrency in Action
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Ryo Okubo
June 27, 2017
Programming
490
1
Share
5 分でやる Rust Concurrency in Action
RustのLT会! Rust入門者の集い #3 で話した資料です。
https://rust.connpass.com/event/56276/
Ryo Okubo
June 27, 2017
More Decks by Ryo Okubo
See All by Ryo Okubo
UbieのAIパートナーを支えるコンテキストエンジニアリング実践
syucream
3
1.5k
メルカリ・メルペイの成長を支える データ基盤とはどんなものか
syucream
7
7.3k
バッチとストリーミング、それぞれの障害に立ち向かう
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
680
マイクロサービスにおける ログ収集の課題と取り組み
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
密結合なバックエンドから TypeScript のコードを生成する
kemuridama
0
160
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
390
〜バイブコーディングを超えて〜 チームで実験し続けたAI駆動開発
tigertora7571
0
210
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
370
PHPでバイナリをパースして理解するASN.1
muno92
PRO
0
460
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
28
23k
Making the RBS Parser Faster
soutaro
0
720
ハーネスエンジニアリングとは?
kinopeee
13
7k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
720
How We Practice Exploratory Testing in Iterative Development( #scrumniigata ) / 反復開発の中で、探索的テストをどう実施しているか
teyamagu
PRO
3
850
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
3.1k
Agentic AI & UI: Arcitecture, HITL, Emerging Standards
manfredsteyer
PRO
0
110
Featured
See All Featured
The Mindset for Success: Future Career Progression
greggifford
PRO
0
330
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
Abbi's Birthday
coloredviolet
2
7.6k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
Utilizing Notion as your number one productivity tool
mfonobong
4
300
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Optimizing for Happiness
mojombo
378
71k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
370
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
140
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
220
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
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++ でやるより楽だよねというはなし –
ただし万能なわけではないよ