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
select文の内部実装見つけました
Search
H.Saki
August 11, 2021
Technology
1
710
select文の内部実装見つけました
21/8/11 GeekGig #1 〜Goと私の一年〜にて発表
https://showcase-gig.connpass.com/event/217914/
H.Saki
August 11, 2021
Tweet
Share
More Decks by H.Saki
See All by H.Saki
Goの格言”Errors are values”の本質を読み解く
sakiengineer
11
2.5k
どうしてもcgoから逃げられなくなったあなたに知ってほしいcgoの使い方入門
sakiengineer
1
2.3k
アプリ側のコードを書いていた人がLambdaに触れて気づいたこと
sakiengineer
0
1.5k
epollによるNetwork I/O in Goランタイム
sakiengineer
3
2k
スケジューラから学ぶGoランタイム 〜code reading of runtime pkg〜
sakiengineer
12
4.7k
Other Decks in Technology
See All in Technology
#TRG24 / David Cuartielles / Post Open Source
tarugoconf
0
570
完全自律型AIエージェントとAgentic Workflow〜ワークフロー構築という現実解
pharma_x_tech
0
330
AWS re:Invent 2024 re:Cap Taipei (for Developer): New Launches that facilitate Developer Workflow and Continuous Innovation
dwchiang
0
160
.NET 最新アップデート ~ AI とクラウド時代のアプリモダナイゼーション
chack411
0
200
信頼されるためにやったこと、 やらなかったこと。/What we did to be trusted, What we did not do.
bitkey
PRO
0
2.1k
OPENLOGI Company Profile
hr01
0
58k
GeometryReaderやスクロールを用いた表現と紐解き方
fumiyasac0921
0
100
Docker Desktop で Docker を始めよう
zembutsu
PRO
0
150
My small contributions - Fujiwara Tech Conference 2025
ijin
0
1.4k
WantedlyでのKotlin Multiplatformの導入と課題 / Kotlin Multiplatform Implementation and Challenges at Wantedly
kubode
0
240
データ基盤におけるIaCの重要性とその運用
mtpooh
4
460
0→1事業こそPMは営業すべし / pmconf #落選お披露目 / PM should do sales in zero to one
roki_n_
PRO
1
1.2k
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
How STYLIGHT went responsive
nonsquared
96
5.3k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.6k
Faster Mobile Websites
deanohume
305
30k
Fireside Chat
paigeccino
34
3.1k
Automating Front-end Workflow
addyosmani
1366
200k
How GitHub (no longer) Works
holman
312
140k
BBQ
matthewcrist
85
9.4k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
Bash Introduction
62gerente
610
210k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
Transcript
select文の内部実装見つけました GeekGig #1, AUG 11 2021 さき(H.Saki) @saki-engineer
About Me 自己紹介 l ͖͞ )4BLJ ◦ ౦େֶ෦ ˠ ࠓ͔Β৽ࣾձਓ
ݚमத ◦ 5XJUUFS!TBLJFOHJOFFS l աڈͷՌ FUDʜ
TFMFDUจͰɺதʹDBTFจΛॻ͘͜ͱͰॲཧͷذΛ࣮ݱ͍ͯ͠Δɻ Select statements select文 var i1, i2 int var ch1,
ch2 chan int select { case i1 = <-ch1: print("received ", i1, " from c1∖n") case ch2 <- i2: print("sent ", i2, " to c2∖n") default: print("no communication∖n") } νϟωϧDI͔Βͷड৴͕Մೳͳͱ͖࣮ߦ νϟωϧDIͷૹ৴͕Մೳͳͱ͖࣮ߦ ͍ͣΕͰͳ͍߹ʹ࣮ߦ EFGBVMUDBTF͕ͳ͚ΕϒϩοΫ
runtime/select.go runtime/select.go ߦʹʮ͜ͷϑΝΠϧʹTFMFDUจͷؚ࣮͕·Ε͍ͯ·͢ʯͱͷهࡌ͋Γ
runtime/select.go runtime/select.go TFMFDUจຊମͷهड़ɺ-ͷ GVOD TFMFDUHP ͰߦΘΕ͍ͯΔɻ // selectgo implements the
select statement. func selectgo(cas0 *scase, order0 *uint16, pc0 *uintptr, nsends, nrecvs int, block bool) (int, bool) { // (略) // 400行くらいある }
None
ͪΐͬͱԿݴͬͯΔ͔Θ͔Μͳ͍
͜Μͳͱ͖ίϝϯτʹண͠Α͏ʂ
Implementation of select statement select文の実装 ϒϩοΫ͠ͳͯ͘Α͍߹͔Β࣮͍ͯ͠Δ͜ͱ͕֬ೝͰ͖Δɻ TFMFDU͢Δରͷத͔Βૹड৴Ͱ͖Δ νϟωϧ͕ͳ͍͔Λ୳͍ͯ͠ΔͬΆ͍ l νϟωϧ͔Βड৴ՄˠSFDW
l όοϑΝ͔Βड৴ՄˠCVGSFDW l νϟωϧDMPTFࡁΈˠSDMPTF ͔ͳʁͱ͍͏Ծઆ͕༰қʹཱͭ
Implementation of select statement select文の実装 ͦͷ࣍ʹɺϒϩοΫʹೖΔ߹ͷॲཧΛॻ͍͍ͯΔɻ ૹड৴Ͱ͖Δνϟωϧ͕ͳ ͔ͬͨͱ͖ͷॲཧ͔ͳʁ HPQBSLؔͰҎԼͷॲཧΛ࣮ߦ͠ɺTFMFDUจͷCMPDLΛ࣮ݱ
TFMFDUจΛ࣮ߦ͍ͯ͠Δΰʔϧʔνϯͷঢ়ଶΛSVOOJOH͔ΒXBJUJOHʹมߋ ֘ΰʔϧʔνϯΛεϨου͔ΒҰ୴Γ͢
Summary まとめ l TFMFDUจຊମͷ࣮SVOUJNFTFMFDUHPͷதͷTFMFDUHPؔ ◦ େମͷ(PͷجװػೳSVOUJNFύοέʔδͷதʹ͋Δ l ίʔυΛૉʹಡΈղ͔ͳͯ͘ɺ࣮ͷେΛ୳Δ͜ͱͰ͖Δ ख͕͔ΓʹͳΔͷҎԼ ◦
ίϝϯτ ◦ มɾఆɾ໊ؔ ◦ ߏମͷϑΟʔϧυ໊ ◦ ϥϕϧ໊ l ΈΜͳSVOUJNFύοέʔδΛಡ͏;&ˑ
5IBOLZPVGPSMJTUFOJOH