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

Hello, Swift Concurrency world.の振り返り / Looking back on Hello, Swift Concurrency world.

Cc8ec9594b83b5dc3c7eef345c05dc8d?s=47 shiz
September 24, 2021

Hello, Swift Concurrency world.の振り返り / Looking back on Hello, Swift Concurrency world.

This is the continuation of "Hello, SwiftConcurrency world." at iOSDC Japan 2021.

Cc8ec9594b83b5dc3c7eef345c05dc8d?s=128

shiz

September 24, 2021
Tweet

Transcript

  1. -PPLJOHCBDLBUJ04%$+BQBO 
 TIJ[ )FMMP 4XJGU$PODVSSFODZXPSME 
 ͷৼΓฦΓ Ћ

  2. ΞδΣϯμ w4XJGU$PODVSSFODZͱߏ଄Խϓϩάϥϛϯά wσʔλڝ߹๷ࢭͷஈ֊తಋೖ

  3. 4XJGU$PODVSSFODZͱߏ଄Խϓϩάϥϛϯά

  4. ߏ଄Խϓϩάϥϛϯά IUUQTFXPSETKQXߏ଄ԽϓϩάϥϛϯάIUNM ίϯϐϡʔλϓϩάϥϜͷ։ൃ΍ཧղɺमਖ਼Λԁ׈ʹߦ͑Δ Α͏ɺϓϩάϥϜΛ੔ཧ͞Εͨߏ଄ͷ૊Έ߹ΘͤʹΑͬͯߏ ੒͢Δ͜ͱɻҰൠతʹ͸ w ॱ઀ هड़ͨ͠ॱ൪ʹ࣮ߦ͢Δ  w

    ෼ذ ࢦఆ͞Εͨ৚݅Λຬ͔ͨ͢൱͔Ͱࢬ෼͔Ε͢Δ  w ൓෮ ࢦఆ͞Εͨ৚͕݅੒Γཱͭؒ܁Γฦ͢  ͷࡾͭͷ੍ޚߏ଄ʹΑͬͯॲཧͷྲྀΕΛهड़͢Δ͜ͱͰ͋Δ ͱཧղ͞Ε͍ͯΔɻ
  5. ؔ਺Λൈ͚ͨޙ Ͳ͔͜ͷ࣌఺Ͱ࣮ߦ͞ΕΔ ݁ՌΛड͚औΔλΠϛϯά࣍ୈ ίʔϧόοΫܗࣜͷඇಉظॲཧ ίʔϧόοΫ࣮ߦલʹείʔϓΛൈ͚Δ

  6. BTZODBXBJU ݁ՌΛ଴ͬͯ࣍ʹਐΉ ্͔ΒԼʹॲཧ͕࣮ߦ͞ΕΔ ͜ͷείʔϓ಺Ͱશͯͷॲཧ͕׬݁͢Δ

  7. GPSϧʔϓ "TZOD4FRVFODF IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOGPVOEBUJPOVSMMJOFT

  8. NFUBEBUB 5BTLUSFF GFUDI0OF5IVNCOBJM EBUB NFUBEBUB 5BTLUSFF GFUDI0OF5IVNCOBJM EBUB NFUBEBUB 5BTLUSFF

    GFUDI0OF5IVNCOBJM EBUB NFUBEBUB 5BTLUSFF GFUDI0OF5IVNCOBJM EBUB 4USVDUVSFE$PODVSSFODZ ໭Γ஋͸<6**NBHF>
  9. ߏ଄Խϓϩάϥϛϯά IUUQTFXPSETKQXߏ଄ԽϓϩάϥϛϯάIUNM ίϯϐϡʔλϓϩάϥϜͷ։ൃ΍ཧղɺमਖ਼Λԁ׈ʹߦ͑Δ Α͏ɺϓϩάϥϜΛ੔ཧ͞Εͨߏ଄ͷ૊Έ߹ΘͤʹΑͬͯߏ ੒͢Δ͜ͱɻҰൠతʹ͸ w ॱ઀ هड़ͨ͠ॱ൪ʹ࣮ߦ͢Δ  w

    ෼ذ ࢦఆ͞Εͨ৚݅Λຬ͔ͨ͢൱͔Ͱࢬ෼͔Ε͢Δ  w ൓෮ ࢦఆ͞Εͨ৚͕݅੒Γཱͭؒ܁Γฦ͢  ͷࡾͭͷ੍ޚߏ଄ʹΑͬͯॲཧͷྲྀΕΛهड़͢Δ͜ͱͰ͋Δ ͱཧղ͞Ε͍ͯΔɻ
  10. σʔλڝ߹๷ࢭͷஈ֊తಋೖ

  11. σʔλڝ߹ͱ͸ʁ wσʔλڝ߹ͱ͸ɺϓϩάϥϜ಺Ͱڞ༗͞ΕͨՄมঢ়ଶ TIBSFE NVUBCMFTUBUF ʹෳ਺ͷεϨου͔Βॻ͖ࠐΈΞΫηεΛؚ Μͩಉ࣌ΞΫηε͕ى͖ͨ݁ՌɺऔΓग़݁͢Ռ͕λΠϛϯά࣍ ୈͰมΘͬͯ͠·͏ݱ৅

  12. "DUPS "DUPST w ϓϩάϥϜ಺Ͱڞ༗͞ΕͨՄมঢ়ଶ΁ɺෳ਺ͷεϨου͔Β ͷಉ࣌ΞΫηεΛ๷͙ɺࢀরܕͷσʔλߏ଄ w TUSVDUɺFOVNɺDMBTTʹ͍ۙػೳΛ͍࣋ͬͯΔ

  13. 4XJGU$PODVSSFODZ3PBENBQ

  14. ஈ֊ͷ"DUPSʹΑΔσʔλڝ߹๷ࢭ wୈஈ֊ 
 "DUPSΛར༻͍ͯ͠Δ෦෼Ͱσʔλڝ߹Λ๷͙ 
 ྫάϩʔόϧม਺ΛHMPCBMBDUPSʹ͢ΔɻDMBTTΛBDUPSʹม׵͢Δ wୈஈ֊ 
 άϩʔόϧม਺͸HMPCBMBDUPSͰकΒͳ͚Ε͹ͳΒͳ͍ ΋͘͠͸໌

    ࣔతʹνΣοΫର৅֎ʹ͠ͳ͚Ε͹ͳΒͳ͍ 
 DMBTT΍DMBTTΛ಺෦ʹؚΜͩܕ͸σϑΥϧτͰಉ࣌ฒߦॲཧؒͰ࢖ ༻Ͱ͖ͳ͘ͳΔ 4XJGU$PODVSSFODZ3PBENBQ ୈஈ֊ͰTPVSDFCSFBLJOHΛى͜͢Մೳੑ
  15. ͍ͭʁ wݴޠͷϞʔυ όʔδϣϯ ͰมΘΔ w4XJGUϢʔβ͕BTZODBXBJU΍"DUPSʹ׳ΕΔ·Ͱ࣌ؒΛ༩͑Δ 4XJGU$PODVSSFODZ3PBENBQ 4XJGUʜͷ࿩

  16. ஈ֊త4FOEBCMFνΣοΫ ·ͩ1JUDI IUUQTHJUIVCDPN%PVH(SFHPSTXJGUFWPMVUJPOCMPCTFOEBCMFTUBHJOHQSPQPTBMTOOOOTFOEBCMFTUBHJOHNE QJUDI͋Γ

  17. 4FOEBCMF w ಉ࣌ฒߦॲཧؒͰڞ༗ͯ͠΋҆શͳܕΛࣔ͢ϓϩτίϧ 
 !VODIFDLFEΛ෇͚ΔͱνΣοΫΛআ֎Ͱ͖Δ wؔ਺ܕ͸ϓϩτίϧʹ४ڌͰ͖ͳ͍ͨΊ!4FOEBCMFͱ͍͏ଐ ੑΛ࢖༻ w͜Εʹ४ڌ͠ͳ͍ͱίϯύΠϧΤϥʔʹͳΔ৔߹͕͋Δ 5BTLJOJU΍5BTLEFUBDIFEͷҾ਺ͷΫϩʔδϟ಺Ͱ࢖͏ܕͳ Ͳ

  18. 4FOEBCMFνΣοΫͷ໰୊఺ w Ұؾʹ4FOEBCMFνΣοΫΛಋೖͯ͠͠·͏ͱɺ$PODVSSFODZ ʹରԠ͍ͯ͠ͳ͍Ϟδϡʔϧͷܕ͕࢖͑ͳ͘ͳͬͯ͠·͍ɺ։ ൃ͕ਐ·ͳ͘ͳͬͯ͠·͏Մೳੑ΋ 
 ͜͜Ͱݴ͏Ϟδϡʔϧͱ͸ɺࣗ਎ͷϓϩδΣΫτ಺ͷଞͷν ʔϜ͕։ൃ͍ͯ͠ΔϞδϡʔϧ΍ར༻͍ͯ͠ΔϥΠϒϥϦ಺ͷ ϞδϡʔϧΛࢦ͠·͢

  19. 4FOEBCMFνΣοΫͷ໰୊఺ Ϟδϡʔϧ"͕$PODVSSFODZʹରԠ͠ͳ͍ͱܕ͕࢖͑ͳ͍ Ϟδϡʔϧ" $PODVSSFODZରԠલ Ϟδϡʔϧ#

  20. 4FOEBCMFνΣοΫͷ໰୊఺ !VODIFDLFEͰճආͰ͖Δ Ϟδϡʔϧ" Ϟδϡʔϧ#

  21. 4FOEBCMFνΣοΫͷ໰୊఺ 4FOEBCMFνΣοΫ͠ͳ͍ͷͰσʔλڝ߹Λى͜͢ϦεΫ͕͋Δ 
 ؾ͕͖ͭʹ͍͘ Ϟδϡʔϧ" Ϟδϡʔϧ#

  22. طଘΫϥΠΞϯτ΁ͷӨڹ CPEZ͸ಉ࣌ฒߦʹ࣮ߦ͞ΕΔՄೳੑ͕͋ΔͨΊˏ4FOEBCMF͕ඞཁ 
 CPEZͰੜ੒͞ΕΔ໭Γ஋ͷܕ΋4FOEBCMF͕ඞཁ Ϟδϡʔϧ$ $PODVSSFODZରԠલ Ϟδϡʔϧ$ $PODVSSFODZରԠޙ

  23. ໰୊5͕4FOEBCMFʹ४ڌ͍ͯ͠ͳ͍ 
 ໰୊CPEZ͕!4FOEBCMFΫϩʔδϟʹม׵Ͱ͖ͳ͍ طଘΫϥΠΞϯτ΁ͷӨڹ Ϟδϡʔϧ% Ϟδϡʔϧ$ $PODVSSFODZରԠޙ

  24. ஈ֊తͳ4FOEBCMFνΣοΫ w ঃʑʹ4FOEBCMFνΣοΫΛ޿͛Δ ڧΊΔΑ͏ʹ͢Δ w Ϟδϡʔϧ୯ҐͰνΣοΫͷ੍ޚΛͰ͖ΔΑ͏ʹ͢Δ

  25. ஈ֊తͳ4FOEBCMFνΣοΫ w $PODVSSFODZະରԠϞδϡʔϧͷ4FOEBCMFͰ͸ͳ͍ܕ΁ͷν ΣοΫΛɺΤϥʔ͔ΒϫʔχϯάʹԼ͛Δɻ΋͘͠͸νΣο Ϋ͠ͳ͘͢Δ w Ϟδϡʔϧ୯ҐͰͷνΣοΫ੍ޚΛߦ͏ɻ$PODVSSFODZΛద ༻͍ͯ͠ΔϞδϡʔϧͱ͍ͯ͠ͳ͍ϞδϡʔϧͰνΣοΫͷํ ๏Λ۠ผ͢Δ

  26. Ϟδϡʔϧ୯ҐνΣοΫ $PODVSSFODZରԠલ Ϟδϡʔϧ"ͷܕ͸4FOEBCMFͱਪ࿦͞ΕɺϞδϡʔϧ#಺ͰΤϥʔʹͳΒͳ͍ ˞σʔλڝ߹͔Βݫ֨ʹ҆શͰ͸ͳ͍ Ϟδϡʔϧ" $PODVSSFODZରԠલ Ϟδϡʔϧ#

  27. Ϟδϡʔϧ୯ҐͷνΣοΫ $PODVSSFODZରԠޙ 4FOEBCMFͳͷͰΤϥʔʹͳΒͳ͍ Ϟδϡʔϧ" $PODVSSFODZରԠޙ Ϟδϡʔϧ#

  28. OPO4FOEBCMF OPO4FOEBCMFͳͷͰΤϥʔ Ϟδϡʔϧ" $PODVSSFODZରԠޙ Ϟδϡʔϧ# Ϟδϡʔϧ୯ҐͷνΣοΫ $PODVSSFODZରԠޙ

  29. Ϟδϡʔϧ΁$PODVSSFODZΛద༻͢Δํ๏ w 4XJGU9ϞʔυͰίϯύΠϥϑϥά˞Λઃఆ͢Δ 
 ˞ݱࡏͷ໊લ͸XBSODPODVSSFODZ w 4XJGUϞʔυΛઃఆ͢Δ

  30. ໰୊5͕4FOEBCMFʹ४ڌ͍ͯ͠ͳ͍ 
 ໰୊CPEZ͕!4FOEBCMFΫϩʔδϟʹม׵Ͱ͖ͳ͍ طଘΫϥΠΞϯτͷӨڹ Ϟδϡʔϧ$ $PODVSSFODZରԠޙ Ϟδϡʔϧ%

  31. ໰୊5͕4FOEBCMFʹ४ڌ͍ͯ͠ͳ͍ 
 4XJGU9Ͱ͸ϫʔχϯάʹͳΔ ˞ݱঢ়ϫʔχϯά΋ग़ྗ͞Εͳ͍ͷͰࠓޙมΘΔՄೳੑ͋Γ طଘΫϥΠΞϯτ΁ͷӨڹ Ϟδϡʔϧ%

  32. ίϯςΩετʹ߹Θͤͯ!4FOEBCMFʹ΋OPO!4FOEBCMFʹ΋ͳΔ ໰୊CPEZ͕!4FOEBCMFΫϩʔδϟʹม׵Ͱ͖ͳ͍ 
 !VOTBGF4FOEBCMF˞ طଘΫϥΠΞϯτ΁ͷӨڹ Ϟδϡʔϧ$ $PODVSSFODZରԠޙ ˞໊শʹ͍ͭͯ͸ࠓޙมΘΔՄೳੑ͋Γ

  33. !4FOEBCMFͰ͸ͳ͍ͷͰΤϥʔʹͳΒͳ͍ طଘΫϥΠΞϯτ΁ͷӨڹ Ϟδϡʔϧ% $PODVSSFODZରԠલ

  34. ະରԠͰ΋$PODVSSFODZΛ࢖༻͍ͯ͠Δ৔߹͸ 
 !4FOEBCMFͱͯ͠ѻΘΕΔ طଘΫϥΠΞϯτ΁ͷରԠ Ϟδϡʔϧ% $PODVSSFODZରԠલ

  35. ͋ΔϞδϡʔϧͷ4FOEBCMFνΣοΫஈ֊ w 4XJGU9 
 $PODVSSFODZ࢖༻෦෼ͷΈ4FOEBCMFνΣοΫΛͯ͠ϫʔχϯά͕ൃੜ͢Δ 
 !VOTBGF4FOEBCMF͸$PODVSSFODZΛ࢖༻͍ͯ͠Δ෦෼Ͱ͸!4FOEBCMFɺͦ ΕҎ֎͸OPO!4FOEBCMFͱͯ͠ѻΘΕΔ w 4XJGU9

    ίϯύΠϥϑϥά 
 ϞδϡʔϧશମͰ4FOEBCMFνΣοΫΛͯ͠ϫʔχϯά͕ൃੜ͢Δ 
 !VOTBGF4FOEBCMF͸ৗʹ!4FOEBCMFͱͯ͠ѻΘΕΔ w 4XJGU 
 ϞδϡʔϧશମͰ4FOEBCMFνΣοΫΛͯ͠Τϥʔ͕ൃੜ͢Δ 
 ͨͩ͠ɺ$PODVSSFODZະରԠͷϞδϡʔϧͷܕ͸ϫʔχϯά͕ൃੜ͢Δ
  36. ஈ֊తʹಋೖ͢Δ͜ͱͰ w $PODVSSFODZະରԠͳ΋ͷ͕։ൃͷअຐΛ͠ͳ͍ w $PODVSSFODZରԠޙ͸ద੾ʹνΣοΫΛͯ͘͠ΕΔ w ·ͣ4XJGU9ͰϫʔχϯάΛग़ྗ͢Δ͜ͱͰɺ4XJGUͰى͜ɹ ΔΤϥʔʹඋ͑Δ͜ͱ͕Ͱ͖Δ

  37. ຊ೔ͷ·ͱΊ w 4XJGU$PODVSSFODZ͸ߏ଄Խϓϩάϥϛϯά͕ҙࣝ͞Ε͍ͯΔ w σʔλڝ߹ͷνΣοΫʹΑͬͯTPVSDFCSFBLJOH͕ى͜ΔՄೳ ੑ͕ࣔࠦ͞Ε͍ͯΔ͕ɺݴޠͷόʔδϣϯ΍ϑϥάͷ༗ແʹΑ ͬͯঃʑʹରԠ͍͚ͯ͠ΔΑ͏ͳ࢓૊Έ͕४උ͞Ε͍ͯΔ ·ͩ 1JUDIஈ֊ 

    w σʔλڝ߹Λى͜͢Մೳੑ͕͋Δίʔυ͸কདྷతʹΤϥʔʹͳ ΔՄೳੑ͕͋ΔͷͰɺࠓ͔ΒҙࣝΛ͢Δඞཁ͕͋Γͦ͏ άϩ ʔόϧม਺΍DMBTTΛ࢖͍ͬͯΔՕॴͳͲ
  38. ͋Γ͕ͱ͏͍͟͝·ͨ͠

  39. ஈ֊త4FOEBCMFνΣοΫ 1JUDI ௥ه IUUQTHJTUHJUIVCDPNCFDDBEBYDDEFBCBFGDF

  40. جຊతʹ΍Γ͍ͨ͜ͱ͸มΘΒͳ͍

  41. TUSJDUDPODVSSFODZ w લճͷXBSODPODVSSFODZͱಉ͡ w 4XJGU9όʔδϣϯͰίϯύΠϥϑϥάʹࢦఆ͢Δͱɺ 4FOEBCMFνΣοΫ͸ΤϥʔͰ͸ͳ͘શͯܯࠂʹͳΔ

  42. !QSFEJDBUF$PODVSSFODZ w ֎෦͔Βར༻͞ΕΔϥΠϒϥϦ΍ϞδϡʔϧͰ4XJGU $PODVSSFODZΛ࢖༻͍ͨ͠৔߹ʹɺ4FOEBCMFະରԠͷϞδϡ ʔϧͰ࢖༻͢Δࡍͷʮޓ׵ϞʔυʯΛఏڙ͢Δ w 4XJGU9ܥͷ৔߹ɺ͍͔ͭ͘ͷ4FOEBCMFνΣοΫΛ཈੍͢Δ w 4FOEBCMFະରԠͷϞδϡʔϧͰ࢖༻͢Δ৔߹͸4FOEBCMFͱ Έͳ͞Εͳ͍

    4FOEBCMF͕એݴ͔Βফ͑Δ
  43. !4FOEBCMFJNQPSU w 4FOEBCMFະରԠͷϥΠϒϥϦ΍Ϟδϡʔϧͷܕ΍એݴΛ JNQPSUͯ͠4XJGU$PODVSSFODZͰ࢖༻͍ͨ͠৔߹ʹ࢖༻Ͱ͖ Δ w JNQPSUͨ͠Ϟδϡʔϧ͕4FOEBCMFະରԠͷ৔߹͸ɺ 4FOEBCMFνΣοΫΛ཈͑Δ Τϥʔʹ͠ͳ͍ 

    w JNQPSUͨ͠Ϟδϡʔϧ͕4FOEBCMFʹରԠ͢Δͱɺ4FOEBCMF νΣοΫ͕͞ΕΔΑ͏ʹͳΔ
  44. 0CKFDUJWF$એݴͷ4FOEBCMF w 0CKFDUJWF$͔ΒJNQPSUͨ͠ܕ͕4FOEBCMF͔OPO4FOEBCMF Ͱ͸ͳ͍͔ΛϔομϑΝΠϧͰ໌ࣔతʹࢦఆ͢Δ w TXJGU@BUUS l!4FOEBCMF 
 4XJGU͸ແ৚݅ʹ׬શͳ4FOEBCMF΁ͷ४ڌΛ߹੒͢Δ w

    ҉໧తʹTXJGU@BUUS l!4FOEBCMFz ͕෇༩͞ΕΔ 
 BTZODʹม׵͞ΕΔϝιουͷҾ਺ͷDPNQMFUJPO)BOEMFSͷϒϩοΫ 
 FOVN@FYUFOTJCJMJUZ /4@&/6. OT@FSSPS@EPNBJO /4@&3303  fl BH@FOVN /4@015*0/4 TXJGU@XSBQQFS /4@5:1&%@&/6.
  45. w TXJGU@BUUS l!@OPO4FOEBCMF 
 TXJGU@BUUS l!4FOEBCMF ͕࢖͑ΔॴͰ࢖͑Δ 
 ಉ͡એݴ΍ܕʹ෇͍ͨTXJGU@BUUS l!4FOEBCMF

    ͸ແࢹ͞Εͨ w TXJGU@BUUS !@OPO4FOEBCMF @BTTVNFE  
 ಉ͡એݴ΍ܕʹ෇͍ͨTXJGU@BUUS l!4FOEBCMFz ͸ແࢹ͞Εͳ͍ 0CKFDUJWF$એݴͷ4FOEBCMF
  46. 0CKFDUJWF$ϧʔϧ·ͱΊ w TXJGU@BUUS l!@OPO4FOEBCMFz ͳΒ͹໌ࣔతʹOPO4FOEBCMF w TXJGU@BUUS l!4FOEBCMFz ·ͨ͸҉໧తʹ෇༩͞ΕΔ΋ͷ͸໌ ࣔతʹ4FOEBCMF

    w TXJGU@BUUS l!@OPO4FOEBCMF @BVEJUFE z ͳΒ͹໌ࣔతʹ OPO4FOEBCMF w ͪ͜Βʹ߹கͨ͠΋ͷ͸໌ࣔతʹ4FOEBCMF w ͦͷଞ͸OPO4FOEBCMF
  47. 0CKFDUJWF$3FHJPOϕʔενΣοΫ w @@48*'5@"553@46110354@4&/%"#-&@%&$-4ͷ஋Ͱର Ԡͷ༗ແΛࢦఆͰ͖Δ w DMBOHBUUSJCVUFQSBHNBͰར༻Մೳ

  48. *NQSPWJOH4FOEBCMF*OGFSFODF 1JUDI ௥ه IUUQTHJUIVCDPN%PVH(SFHPSTXJGUFWPMVUJPOCMPCTFOEBCMFJOGFSFODFQSPQPTBMTOOOOTFOEBCMFJOGFSFODFNE

  49. 4FOEBCMFͷద߹ͷෛ୲ΛݮΒ͍ͨ͠

  50. SFRVJSFFYQMJDJUTFOEBCMF w ίϯύΠϥϑϥά w ϓϩτίϧҎ֎ͷQVCMJD ·ͨ͸PQFO ͳܕ͸໌ࣔతʹ 4FOEBCMFɺ·ͨ͸OPO4FOEBCMF ˞ Λࢦఆ͠ͳ͚Ε͹ͳΒ

    ͳ͍ɻ 
 ˞OPO4FOEBCMFͷࢦఆํ๏͸ݕ౼த !VOBWBJMBCMF4FOEBCMFͳͲ  wࢦఆ͞Ε͍ͯͳ͍৔߹͸ fi YJU෇͖ͷXBSOJOH͕ग़ྗ͞ΕΔɻج ຊతʹ͸ͦΕʹैͬͯίʔυͷม׵Λߦ͑͹ྑ͍ͷͰɺܕΛ୳ ͯ͠ม׵͢Δͱ͍͏ෛ୲͕ݮΔ