Goroutine meets a signal
by
Kei Kamikawa
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
(PSPVUJOFNFFUTBTJHOBM !(P$POGFSFODF4QSJOH
Slide 2
Slide 2 text
!DPEFIFY !$PEF)FY w *MJLF1FSM94(P w *MJWFJO5PLZPGSPN0LJOBXB w ❤$BQCBUUJOHDFOUFS w .FSDBSJ *OD/FX w IUUQTDPEFIFYIBUFCMPKQ
Slide 3
Slide 3 text
No content
Slide 4
Slide 4 text
Έͳ͞Μ
Slide 5
Slide 5 text
γάφϧͬͯ·͔͢ʁ
Slide 6
Slide 6 text
ͬͯ·͢ΑͶʂ
Slide 7
Slide 7 text
Βͳ͍ਓͷͨΊʹ
Slide 8
Slide 8 text
No content
Slide 9
Slide 9 text
શ͘໘ന͘ͳ͍ʜ
Slide 10
Slide 10 text
% man signal ʮࠓ͙࣮͢ߦʯ
Slide 11
Slide 11 text
Ͳ͏͍͏࣌ʹ γάφϧΛ͍·͔͢ʁ
Slide 12
Slide 12 text
γάφϧΛ͏໘ w ॲཧΛ தஅcऴྃc࠶ىಈ ͍ͨ͠ w ׂΓࠐΈॲཧΛߦ͍͍ͨ w γάφϧΛૹΔ͜ͱͰڍಈΛมߋ͍ͨ͠ͳͲ ʢϨΞέʔεʁʣ
Slide 13
Slide 13 text
γάφϧϓϩηεʹ ૹΓ·͢ΑͶ
Slide 14
Slide 14 text
ߋʹݴ͏ͱ
Slide 15
Slide 15 text
ϓϩηεࢠϓϩηε ͷγάφϧૹ৴Մೳ
Slide 16
Slide 16 text
͔͠͠
Slide 17
Slide 17 text
զʑ͕ѻ͏ͷ HPSPVUJOF
Slide 18
Slide 18 text
HPSPVUJOF γάφϧΛૹΓ͍ͨ
Slide 19
Slide 19 text
͔݁Β
Slide 20
Slide 20 text
HPSPVUJOF γάφϧΛૹ৴Ͱ͖ͳ͍
Slide 21
Slide 21 text
͕ͩ ࣅͨΑ͏ͳ͜ͱͰ͖Δ
Slide 22
Slide 22 text
γάφϧΛ௨͢Δ શͯͷ(PSPVUJOFϒϩʔυΩϟετ
Slide 23
Slide 23 text
ඞཁͳ͜ͱ w ௨༻ͷDIBOOFM w ͲΜͳγάφϧ͕ૹΒΕ͖͔ͯͨ
Slide 24
Slide 24 text
ඞཁͳ͜ͱ w ௨༻ͷDIBOOFM w ͲΜͳγάφϧ͕ૹΒΕ͖͔ͯͨ
Slide 25
Slide 25 text
close(ch)
Slide 26
Slide 26 text
close(ch) DIΛ͍࣋ͬͯΔશͯͷHPSPVUJOF DIBOOFMΛૹ৴͢Δ͜ͱ͕Ͱ͖Δ
Slide 27
Slide 27 text
ඞཁͳ͜ͱ w ௨༻ͷDIBOOFM w ͲΜͳγάφϧ͕ૹΒΕ͖͔ͯͨ
Slide 28
Slide 28 text
signal.Notify(ch)
Slide 29
Slide 29 text
signal.Notify(ch) DI͔Βड͚औΕྑ͍
Slide 30
Slide 30 text
࣮ࡍͷίʔυ
Slide 31
Slide 31 text
γάφϧ௨Λߦ͏ߏମ
Slide 32
Slide 32 text
NBJOͷॲཧ
Slide 33
Slide 33 text
ΊͬͪΌ؆୯
Slide 34
Slide 34 text
͔͠͠ɺզʑ context.Context ཉ͍͠
Slide 35
Slide 35 text
context.Context γάφϧϋϯυϥͷ࣮ γάφϧड͚औΕΔcontext.Context
Slide 36
Slide 36 text
context.Context
Slide 37
Slide 37 text
context.Context w جຊతʹΩϟϯηϧͷͨΊͷDIBOOFMͷड͚͠ Λߦ͏తʹ͏ w context.Value ͋Δ͕ɺࠓճؾʹ͠ͳ͍ w JOUFSGBDFͰ͋Δ
Slide 38
Slide 38 text
context.Context
Slide 39
Slide 39 text
͔͞͞ͳϧʔϧʜ
Slide 40
Slide 40 text
IUUQTHPMBOHPSHQLHDPOUFYU l%POPUTUPSF$POUFYUTJOTJEFBTUSVDU UZQFJOTUFBEʜz func DoSomething(ctx context.Context, arg Arg) error { // ... use ctx ... }
Slide 41
Slide 41 text
ͳΔ΄Ͳ
Slide 42
Slide 42 text
͜͜Ͱ ࣍ͷ63-Λݟ·͠ΐ͏ IUUQTHJUIVCDPN$PEF)FYHPMFUTZOPQTJT
Slide 43
Slide 43 text
No content
Slide 44
Slide 44 text
No content
Slide 45
Slide 45 text
No content
Slide 46
Slide 46 text
context.Context ҰͭͰ྆ํड͚औΕΔ
Slide 47
Slide 47 text
࣮ IUUQTHJTUHJUIVCDPN$PEF)FY DCFECGDBGGECGB
Slide 48
Slide 48 text
ߏମDUYΛ֨ೲ͢Δ
Slide 49
Slide 49 text
ٯߦҝͰ͢Ͷ
Slide 50
Slide 50 text
JOUFSGBDFͷ࣮
Slide 51
Slide 51 text
NBJOͷॲཧ
Slide 52
Slide 52 text
͜ΕͰԿ͕خ͍͠ͷ͔ʁ
Slide 53
Slide 53 text
خ͍͜͠ͱ w ड৴෦ͷίʔυ͕؆ܿʹͳͬͯಡΈ͘͢ͳΔ w γάφϧͷ௨ͱDPOUFYUΩϟϯηϧͷ௨ͷ྆ ํΛγϯϓϧʹॻ͚Δ w ϥοϓ͢ΔલͷDPOUFYUͱͯ͠ѻ͑ΔͷͰ҆৺
Slide 54
Slide 54 text
DPOUFYUͷϥοϓʹ ҙ͢Δ͜ͱ
Slide 55
Slide 55 text
ҙ͢Δ͜ͱ w ֎෦͔ΒԿ͔͠Β௨͕͋ͬͯɺͦΕΛτϦΨʔʹ ֤HPSPVUJOF௨͍ͨ͠߹ྑͦ͞͏ w ΉΈʹϥοϓ͢Δͱத͕͔Βͳ͍ɺҙਤ͕Θ ͔Βͳ͍͕ൃੜ͢Δ
Slide 56
Slide 56 text
༷ʑͳؾ͕࣋ͪ͋Δͱ ࢥ͍·͕͢
Slide 57
Slide 57 text
͝੩ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠ 1MFBTFEJTDVTTXJUINF