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
5 分でやる Rust Concurrency in Action
Search
Ryo Okubo
June 27, 2017
Programming
500
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
気軽に使える"情報のハブ"としてのNotion活用 〜フロー情報の集積点 と、 Claude Code × Notion AI〜
syucream
1
300
UbieのAIパートナーを支えるコンテキストエンジニアリング実践
syucream
3
1.7k
メルカリ・メルペイの成長を支える データ基盤とはどんなものか
syucream
6
7.5k
バッチとストリーミング、それぞれの障害に立ち向かう
syucream
3
3.9k
How Scala works at Mercari
syucream
2
1.2k
Production-ready stream data pipeline in Merpay, Inc
syucream
2
13k
データとML周辺エンジニアリン グを考える会 #2 イントロ
syucream
0
690
マイクロサービスにおける ログ収集の課題と取り組み
syucream
7
2.8k
Stream Data Pipeline for Microservices in Merpay
syucream
6
1.3k
Other Decks in Programming
See All in Programming
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
170
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
SREの越境 / SRE Collaboration
y0hgi
2
290
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
3
1k
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
310
The Rails Doctrine Decade
koic
2
460
iOSDC2026登壇資料.pdf
riofujimon
0
200
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
590
JRuby: Past, Present, and Future
headius
0
220
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
110
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
120
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
390
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
580
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
560
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Crafting Experiences
bethany
1
370
GitHub's CSS Performance
jonrohan
1033
470k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
From π to Pie charts
rasagy
1
380
WENDY [Excerpt]
tessaabrams
14
40k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
620
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++ でやるより楽だよねというはなし –
ただし万能なわけではないよ