Slide 1

Slide 1 text

.PSJ"UTVTIJ ,PUMJO$PSPVUJOFTͰ 
 ڞ༗Ϧιʔεʹਖ਼͘͠ΞΫηε͢Δ ,PUMJO'FTU ,PUMJOݴޠɾϓϩάϥϛϯά

Slide 2

Slide 2 text

LINEϠϑʔגࣜձࣾ / Android
 2019೥౓ ະ౿εʔύʔΫϦΤʔλ Mori Atsushi X: @at_sushi_at IUUQTHJUIVCDPNNPSJBUTVTIJ

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

"

Slide 5

Slide 5 text

$PSPVUJOFͷىಈ

Slide 6

Slide 6 text

Slide 7

Slide 7 text

ࠓճͷΰʔϧ Kotlin CoroutinesΛ࢖ͬͯɺ
 ࣗ৴Λ࣋ͬͯڞ༗ϦιʔεΛѻ͑ΔΑ͏ʹ͢Δ 1. ڝ߹ঢ়ଶ͕ൃੜ͢Δཧ༝ͱղܾํ๏ 2. ୯ҰεϨουͷࡍʹؾΛ͚ͭΔ΂͖఺ 3. ԋश໰୊ 🚀

Slide 8

Slide 8 text

ڝ߹ঢ়ଶ͕ൃੜ͢Δཧ༝ͱ
 ղܾํ๏ 1

Slide 9

Slide 9 text

࠶ܝ

Slide 10

Slide 10 text

஋ΛಡΈऔͬͯॻ͖ࠐΉ

Slide 11

Slide 11 text

ݪҼɿಉ࣌ʹߋ৽͕૸Δ J εϨου εϨου UFNQ UFNQ J J

Slide 12

Slide 12 text

ϒϩοΫ಺͸ಉ࣌ʹ͔ͭ͠ॲཧ͞Εͳ͍

Slide 13

Slide 13 text

MutexʹΑΔϩοΫ J εϨου εϨου UFNQ UFNQ J NVUFY ϩοΫ J ϩοΫղআ ϩοΫதͷͨΊ଴ػ ϩοΫղআ ϩοΫ

Slide 14

Slide 14 text

૿΍ͨ͠΋ͷΛฦؔ͢਺ εϨου҆શͳ*OUFHFS ѻ͍͍ͨσʔλʹରԠͨ͠λΠϓ͕ଘࡏ͠ͳ͍৔߹͸࢖͑ͳ͍ ,PUMJO/BUJWFͰ͸"UPNJD*OU͕࢖͑Δ

Slide 15

Slide 15 text

ϒϩοΫ಺͸ಉ࣌ʹ͔ͭ͠ॲཧ͞Εͳ͍

Slide 16

Slide 16 text

ؔ਺͸ಉ࣌ʹ͔̍ͭ͠ॲཧ͞Εͳ͍

Slide 17

Slide 17 text

MutexͱSynchronizedͷҧ͍ MutexɿϒϩοΫ͞Ε͍ͯΔؒɺͦͷCoroutine͸தஅঢ়ଶʹͳΔ SynchronizedɿϒϩοΫ͞Ε͍ͯΔؒɺεϨουΛઐ༗͠ଓ͚Δ CoroutinesΛ࢖͍ͬͯΔ৔߹ → Mutex
 suspendͰͳ͍ؔ਺ → Synchronized

Slide 18

Slide 18 text

ෳ਺ͷεϨουͰಉ͡ϦιʔεΛ
 ѻ͏৔߹ɿ
 - AtomicInteger౳ͷεϨου҆શͳ
 λΠϓΛ࢖͏ - Mutex΍SynchronizedͰϩοΫ͢Δ 💡

Slide 19

Slide 19 text

୯ҰεϨουͷࡍʹ
 ؾΛ͚ͭΔ΂͖఺ 2

Slide 20

Slide 20 text

Dispatcherͷछྨ Dispatchers.Main: UIॲཧ Dispatchers.Default: όοΫάϥϯυॲཧ
 Dispatchers.IO: ωοτϫʔΫ΍DBΞΫηε౳

Slide 21

Slide 21 text

Dispatcherͷछྨ Dispatchers.Main: UIॲཧ Dispatchers.Default: όοΫάϥϯυॲཧ
 Dispatchers.IO: ωοτϫʔΫ΍DBΞΫηε౳ εϨου ෳ਺εϨου ෳ਺εϨου

Slide 22

Slide 22 text

εϨου͔ͩΒڝ߹ঢ়ଶ͸ى͖ͳ͍ʁ

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

ճݺ͹ΕΔ

Slide 25

Slide 25 text

ݪҼɿFetchதʹॲཧ͞ΕΔͨΊ MBTU'FUDIFE"U.JMMJT $PSPVUJOF $PSPVUJOF GFUDI ʜ GFUDI ʜ

Slide 26

Slide 26 text

౓ͷΈݺ͹ΕΔ ϩοΫͯ͠ಉ࣌ʹ࣮ߦ͞Εͳ͍Α͏ʹ͢Δ

Slide 27

Slide 27 text

౓ͷΈݺ͹ΕΔ 4VTQFOEؔ਺ͷݺͼग़͠લʹߋ৽͢Δ ϝΠϯεϨου͔Βݺͼग़͢ඞཁ͕͋Δ͜ͱΛ໌ࣔ BOESPJEYBOOPUBUJPO

Slide 28

Slide 28 text

ίϯύΠϧΤϥʔ suspendؔ਺ʹSynchronized͸࢖͑ͳ͍

Slide 29

Slide 29 text

୯ҰεϨουͰಉ͡ϦιʔεΛ
 ѻ͏৔߹ɿ
 - ಡΈࠐΈͱॻ͖ࠐΈͷؒʹsuspend ؔ਺͕ೖΔ৔߹ʹ஫ҙ͕ඞཁ - MutexͰϩοΫՄೳ 💡

Slide 30

Slide 30 text

ԋश໰୊ 3

Slide 31

Slide 31 text

ෳ਺εϨουͰݺͼग़͍ͨ͠ ԋश̍

Slide 32

Slide 32 text

.VUFYͰϩοΫ͢Δ

Slide 33

Slide 33 text

εϨου҆શͳ 
 .VUBCMF4UBUF'MPXVQEBUF Λ࢖͏

Slide 34

Slide 34 text

GVODUJPO͸ෳ਺ճ 
 ݺͼग़͞ΕΔՄೳੑ͕͋Δ function಺ʹ෭࡞༻Λ࣋ͨͤͯ͸͍͚ͳ͍

Slide 35

Slide 35 text

FNJU͸ ෳ਺εϨου͔Β҆શʹݺͼग़ͤΔ ͜͜͸ಉ͡εϨουʹͳΔ $IBOOFMͰ΋Մ

Slide 36

Slide 36 text

ԋश2 TVTQFOEGVODUJPO

Slide 37

Slide 37 text

.VUFYͰϩοΫ͢Δ

Slide 38

Slide 38 text

.VUFYͰϩοΫ͢Δ ҟͳΔIDͷϢʔβʔΛಉ࣌ʹऔಘͰ͖ͳ͍

Slide 39

Slide 39 text

*%͝ͱʹϩοΫΛ࡞੒͢Δ *%͝ͱͷϩοΫΛऔಘ͢ΔͨΊʹ 
 ϩοΫ͢Δඞཁ͕͋Δ

Slide 40

Slide 40 text

%FGGFSFEΛ࡞Δ͚ͩͳͷͰTVTQFOEঢ়ଶʹͳΒͳ͍ ΞϓϦέʔγϣϯείʔϓͷ$PSPVUJOF4DPQF 6TFSͷ୅ΘΓʹ%FGGFSFEΛอ࣋͢Δ .BQͷૢ࡞͸ϩοΫதʹߦ͏

Slide 41

Slide 41 text

εϨου҆શͳ.VUBCMF.BQ IUUQTHJUIVCDPNUPVDIMBC4UBUFMZ +7.ͳΒ$PODVSSFOU)BTI.BQ͕࢖͑Δ

Slide 42

Slide 42 text

ඇಉظॲཧ͸૝૾Ҏ্ʹෳࡶ
 - Ͱ͖Δ͚ͩ1εϨουͰѻ͑ΔΑ͏ʹ͢Δ - ෳ਺Coroutine͔ΒΞΫηε͞ΕΔڞ༗ Ϧιʔε͸Ͱ͖Δ͚ͩݮΒ͢ - ෳ਺ͷղܾࡦ͔Βγϯϓϧͳ΋ͷΛબͿ 🚀