Upgrade to Pro — share decks privately, control downloads, hide ads and more …

select文の内部実装見つけました

H.Saki
August 11, 2021

 select文の内部実装見つけました

21/8/11 GeekGig #1 〜Goと私の一年〜にて発表

https://showcase-gig.connpass.com/event/217914/

H.Saki

August 11, 2021
Tweet

More Decks by H.Saki

Other Decks in Technology

Transcript

  1. About Me 自己紹介 l ͖͞ )4BLJ ◦ ౦େ޻ֶ෦ ˠ ࠓ೥͔Β৽ࣾձਓ

    ݚमத ◦ 5XJUUFS!TBLJFOHJOFFS l աڈͷ੒Ռ෺ FUDʜ
  2. 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͕ͳ͚Ε͹ϒϩοΫ
  3. 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行くらいある }