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

Swift New Concurrency Talk

Swift New Concurrency Talk

Talk about Swift New Concurrency

[email protected]

February 19, 2021
Tweet

Other Decks in Programming

Transcript

  1. શ߲໨ w$PODVSSFODZ3PBENBQ w"TZODBXBJU wSFBTZOD w4USVDUVSFE$PODVSSFODZ w5BTL"1* wBTZODMFU w$POUJOVBUJPOTGPSJOUFSGBDJOHBTZODUBTLTXJUITZODISPOPVTDPEF w5BTL-PDBM7BMVFT w"DUPS

    w(MPCBM"DUPS w"TZODISPOPVT)BOEMFST w1JUDI$PODVSSFOU7BMVFBOE!DPODVSSFOUDMPTVSFT w1SFWFOUJOH%BUB3BDFTJOUIF4XJGU$PODVSSFODZ.PEFM w$VTUPN&YFDVUPS w"TZOD4FRVFODFT w3FUISPXJOH$POGPSNBODFT w1JUDI&GGFDUGVM3FBEPOMZ1SPQFSUJFT w$PODVSSFODZ*OUFSPQFSBCJMJUZXJUI0CKFDUJWF$
  2. BTZODBXBJUͱ͸ʁ w ඇಉظॲཧͷίʔυΛ௨ৗͷ ಉظॲཧͱಉ͡ ࣗવͳྲྀΕͰه ࡌ͢Δ͜ͱ͕Ͱ͖ΔΑ͏ʹͨ͠ϝΧχζϜ w DBMMCBDLʹΑΔෳ਺ͷ໰୊Λղܾ͢Δ w ߏจ্ඇಉظॲཧΛ໌֬ʹ͢Δ͜ͱͰɺݴޠଆͰଟ͘ͷ࠷దԽ

    ͕Ͱ͖Δ 
 ύϑΥʔϚϯεͷ޲্ 
 σόοά΍ϓϩϑΝΠϦϯάɺίʔυݕࡧͳͲͰΑΓΘ͔Γ΍ ͍͢ܗͰͷ৘ใఏڙ 
 ͜ͷઌಋೖ͞ΕΔ$PODVSSFODZؔ࿈ػೳͷ౔୆ͷߏங
  3. BTZODؔ਺ͷ಺෦ಈ࡞  ݺͼग़͠ଆͰҾ਺͕ධՁ͞ΕΔ TZODϝιουͱಉ͡   ݺͼग़͠ઌͷFYFDVUPS͕ܾ·Δ  ݺͼग़͠ଆͱݺͼग़͠ઌͷFYFDVUPS͕ҧ͏৔߹ɺTVTQFOTJPO͕ൃੜͯ͠ɺݺ ͼग़͠ઌͷॲཧͷ࣮ߦ͸ݺͼग़͠ઌͷFYFDVUPSͷΩϡʔʹೖͬͯॱ൪Λ଴ͭ

     ݺͼग़͠ઌͷॲཧ͕ݺͼग़͠ઌͷFYFDVUPS্Ͱ࣮ߦ͞ΕΔ  ݺͼग़͠ઌ͔ΒͷSFUVSOΛड͚औΔࡍɺݺͼग़͠ଆͱݺͼग़͠ઌͷFYFDVUPS͕ ҧ͏৔߹ɺTVTQFOTJPO͕ൃੜͯ͠ɺݺͼग़͠ଆͷॲཧͷ࣮ߦ͸ݺͼग़͠ଆͷ FYFDVUPSͷΩϡʔʹೖͬͯॱ൪Λ଴ͭ  ݺͼग़͠ଆͷॲཧ͕ݺͼग़͠ଆͷFYFDVUPS্Ͱ࣮ߦ͞ΕΔɻݺͼग़͠ઌ͕ਖ਼ৗ ʹSFUVSO͍ͯͨ͠৔߹͸ͦͷ··ॲཧ͕ܧଓ͞ΕΔ͕ɺݺͼग़͠ઌ͕FSSPSΛ UISPX͍ͯͨ͠৔߹͸ɺݺͼग़͠ଆ΋FSSPSΛUISPX͢Δ
  4. 4USVDUVSFE$PODVSSFODZͱ͸ʁ w BTZODؔ਺಺Ͱ$PODVSSFODZॲཧΛ࣮ݱ͢Δ BTZOD BXBJUࣗମ͸BTZODؔ਺಺ͷTVTQFOTJPOQPJOU͸ߟྀ ͞Ε͍ͯͳ͍  w શͯͷBTZODؔ਺Λඇಉظͷ5BTLͷҰ෦ͱ࣮ͯ͠ߦ͢ Δ

    w είʔϓ಺Ͱͷෳ਺ͷ5BTLͷΩϟϯηϧॲཧ΍1SJPSJUZ ͷίϯτϩʔϧɺ৘ใͷڞ༗ͳͲΛΘ͔Γ΍͘͢ɺޮ཰ తʹ࣮૷Ͱ͖ΔΑ͏ʹ͢Δ
  5. 5BTLT 8IBU w 4XJGU$PODVSSFODZͷجຊ୯Ґ w શͯͷBTZODؔ਺͸͋Δ5BTLͷҰ෦ͱ࣮ͯ͠ߦ͢Δ TZOD ؔ਺͸5BTLͰ࣮ߦ͞ΕΔͱ͸ݶΒͳ͍  w

    5BTL͸Ұ౓ʹҰͭͷؔ਺Λ࣮ߦ͢Δ 5BTL಺Ͱ $PODVSSFODZ͸ൃੜ͠ͳ͍  w 5BTLͷதͰBTZODΛ࢖ͬͨ৔߹ɺͦͷBTZODॲཧ͸ಉ͡ 5BTLͷҰ෦ͱ࣮ͯ͠ߦ͞ΕΔɻͦͷࡍɺݺͼग़͠ଆ͸݁Ռ Λ଴ػ͢Δ w ಉ༷ʹͦͷBTZODॲཧͷ݁Ռ͕ฦ͖ͬͯͨΒݺͼग़͠ଆ΋ ಉ͡5BTLͷҰ෦ͱͯ͠ॲཧΛ࠶։͢Δ
  6. 5BTLͷͭͷ4UBUF 8IBU w 4VTQFOEFE ࣮ߦ͢Δॲཧ͕͋Δ͕ɺݱࡏ͸࣮ߦ͞Ε͍ͯͳ͍ 
 ࣮ߦ४උ͸Ͱ͖͍ͯΔ͕ɺ։࢝Λ଴͍ͬͯΔঢ়ଶ 
 ࣮ߦ։࢝Ͱ͖ΔͨΊʹ֎෦ͷΠϕϯτΛ଴͍ͬͯΔঢ়ଶ 3VOOJOH

    ࣮ߦத 
 શͯͷॲཧΛ࣮ߦͯ͠DPNQMFUFEʹͳΔ͔ɺ͞Βʹ಺෦ͷ TVTQFOTJPOQPJOUʹ౸ୡͯ͠TVTQFOEFEʹͳΔ w $PNQMFUFE શॲཧ͕׬ྃͯ͠ɺଞͷঢ়ଶʹ͜ΕҎ্มΘΒͳ͍ 
 ίʔυ্͸BXBJUͳͲͰ5BTL͕DPNQMFUFEʹͳΔ͜ͱΛ଴ͬͯ ͍Δ
  7. $IJME5BTL 8IBU w BTZODؔ਺ 5BTL ͸$IJME5BTLΛ࡞੒Ͱ͖ Δ w $IJME5BTL͸1SJPSJUZͳͲ1BSFOU5BTLͷ ߏ଄Λܧঝ͠ɺ1BSFOU5BTLͷதͰಉ࣌ฒྻ

    ʹ࣮ߦͰ͖Δ w $IJME5BTLΛ࡞੒ͨ͠BTZODؔ਺͸શͯͷ $IJME5BTLͷ࣮ߦ׬ྃΛ଴ͨͳ͚Ε͹ͳΒ ͳ͍
  8. "DUPS͸ෳ਺ͷந৅֓೦ΛҰͭʹ·ͱΊͨ΋ͷ  ֤"DUPSΠϯελϯε͸($%ΩϡʔͷΑ͏ͳ΋ͷΛ֓೦త ʹؚΜͩ$PODVSFODZͷ୯Ґ  ଞͷ$PODVSSFODZυϝΠϯ ଞͷ"DUPS΍εϨου ͔Βඇ ಉظʹϝοηʔδ͕ૹΒΕͯ͘Δ 

    Ұ࿈ͷNVUBCMF Մม ঢ়ଶΛΧϓηϧԽͯ͠ɺϝϞϦʔΛ ଞ͔Βִ཭͢Δ ͜ͷՄมঢ়ଶ͸JEFOUJUZΛ࣋ͭ   4XJGUϓϩάϥϚʹ5BTLϕʔεͷ$PODVSSFODZϓϩάϥ ϛϯάͷʮ҆શͳඪ४ʯσβΠϯύλʔϯΛఏڙ͢Δ IUUQTEPDTHPPHMFDPNEPDVNFOUEFQZ#UL1SBL-D&)7$NR/#L/JC9*;TP[E;&D
  9. BDUPS ᶃ✉ BTZODDBMM ᶄ✉ BTZODDBMM ᶅ✉ BTZODDBMM ᶃ✉ ᶄ✉ ᶅ✉

    📨 BDUPS֎͔ΒBDUPSJTPMBUFE΁ΞΫηε 
 DSPTTBDUPSSFGFSFODFT $SPTTBDUPSSFGFSFODFT
  10. ؔ਺ܕ w ؔ਺ܕ͸1SPUPDPMʹద߹Ͱ͖ͳ͍ࢀরܕ w 4XJGUͷؔ਺͸ɺάϩʔόϧؔ਺ɺOFTUFEؔ਺ɺ BDDFTTPS HFUUFS TFUUFS TVCTDSJQUͳͲ ɺ

    DMPTVSFͳͲ৭ʑͳܗΛ͍࣋ͬͯΔ w ؔ਺ܕΛ$PODVSSFODZؒͰ౉ͤΔ͜ͱͰɺ)JHIFS PSEFSGVODUJPO ߴ֊ؔ਺ Λ4XJGU$PODVSSFODZ Ͱར༻Ͱ͖ΔΑ͏ʹ͢Δ͜ͱ͸༗༻Ͱ͋Γͱͯ΋ॏཁ
  11. 5ISPXFSSPST ໰୊ ؔ਺΍DMPTVSF͸&SSPSʹద߹ͨ͠ͲΜͳܕͷ஋΋UISPXT͢Δ͜ͱ ͕Ͱ͖ɺ$PODVSSFOUͰ͜ͷؔ਺ DMPTVSF ͕࣮ߦ͞ΕΔ৔߹ɺ UISPXO͞ΕΔ஋΋DPODVSSFOUؒ BDUPSؒͳͲ Ͱ౉͞ΕΔ͜ͱʹ ͳΔ

    NZ"DUPSEP4PNFUIJOH3JTLZ ͕ଞͷ $PODVSSFODZͳྖҬ͔Βݺ͹Εͨ࣌ɺNZ"DUPSͷ NVUBCMFͳঢ়ଶΛDBQUVSFͯ͠1SPCMFNBUJD&SSPSΛ UISPX͠Α͏ͱ͍ͯ͠Δ"DUPSJTPMBUJPOҧ൓ ͜ͷ۩ମతͳ&SSPSͷܕ৘ใ͕ͳ͘ ࠓͷ··ͩͱ&SSPS͕$PODVSSFOU7BMVFʹద߹͍ͯ͠ Δ͔ͷνΣοΫ͕Ͱ͖ͳ͍
  12. 4UBOEBSE-JCSBSZͷܕ΁ͷద߹ ྫ֎ w .BOBHFE#V ff FSCV ff FS΁ͷNVUBCMFͳࢀরΛఏڙ͢Δͨ Ί$PODVSSFOU7BMVFʹద߹ͯ͠͸͍͚ͳ͍ w

    6OTBGF .VUBCMF #V ff FS 1PJOUFSແ৚݅Ͱ 6OTBGF$PODVSSFOU7BMVFʹద߹͢Δ w -B[ZBMHPSJUINBEBQUFSUZQFT$PODVSSFOU7BMVFʹద ߹͠ͳ͍ɻଟ͘ͷ΋ͷ͸OPO!DPODVSSFOUͳDMPTVSFΛҾ ਺ʹऔΔͨΊɺ҆શʹద߹Ͱ͖ͳ͍BSSBZMB[ZNBQ\ʜ^ͳͲ w ٯʹ্هҎ֎ͷTUSVDU FOVN DMBTT͸$PODVSSFOU7BMVFʹ ద߹͢ΔΑ͏ʹͳΔ
  13. JNQPSUͨ͠$0CKFDUJWF$"1*΁ͷαϙʔτ w $ݴޠͷίʔυ͸҉໧తʹ$PODVSSFOUʹར༻͢Δͷ͸҆શ Ͱ͸ͳ͍ 4XJGU͔Β$ݴޠ"1*ʹਖ਼͍͠ڍಈΛڧ੍ͤ͞Δ͜ͱ ͕Ͱ͖ͳ͍  w ͔͠͠ɺଟ͘ͷ$ݴޠͷܕʹ҉໧తͳ$PODVSSFOU7BMVF΁ͷ ద߹Λఏڙ͢Δ͜ͱͰ$PODVSSFOUʹར༻Ͱ͖ΔΑ͏ʹ͢Δ

    
 $FOVN͸ৗʹ$PODVSSFOU7BMVFʹద߹͢Δ 
 $TUSVDU͸಺෦ͷTUPSFEQSPQFSUZ͕શͯ$PODVSSFOU7BMVFͳΒ ͹$PODVSSFOU7BMVFʹద߹͢Δ 
 $ؔ਺ϙΠϯλ͸$PODVSSFOU7BMVFʹద߹͢Δ ஋ΛDBQUVSFͰ͖ͳ ͍
  14. ϑΣʔζ w ৽͍͠$PODVSSFODZͷ࢓૊Έ BTZODBXBJU΍"DUPS Λ࢖༻ͨ͠Օॴ ͸ɺઌ΄ͲͷϧʔϧΛकΒͳ͚Ε͹ͳΒͳ͍ w طଘͷίʔυʹؔͯ͠͸͜Ε·Ͱ௨ΓʹίϯύΠϧՄೳ ྫ طଘίʔυ಺ͷσʔλڝ߹ΛҾ͖ى͜͢Մೳੑͷ͋ΔHMPCBMม਺ʹɺ

    HMPCBMBDUPSͷΞϊςʔγϣϯΛ෇༩͢Δ͜ͱͰɺͦͷม਺͸ $PODVSSFODZʹ૊Έࠐ·ΕɺHMPCBMBDUPSͷҰ෦ͱͯ͠TFSJBM FYFDVUPSͷதͰBTZODʹΞΫηε͢ΔΑ͏ʹͳΔͨΊɺσʔλڝ߹Λ๷͙ ͜ͱ͕Ͱ͖ΔΑ͏ʹͳΔ BDUPSΛ࢖༻͢Δ৔߹ɺͦΕΛར༻͢ΔՕॴͰ͸$PODVSSFODZʹͳΔͨ Ίɺσʔλڝ߹Λ๷͙͜ͱ͕Ͱ͖Δ
  15. ·ͱΊ w $PODVSSFODZॲཧΛΑΓѻ͍΍͘͢ɺ҆શʹߦ͑Δ࢓૊Έ͕ͨ ͘͞Μಋೖ͞ΕΔ w ద੾ʹѻ͑Ε͹͜Ε·ͰҎ্ʹ҆શʹ։ൃΛਐΊ͍ͯ͘͜ͱ͕Ͱ ͖Δ w ҰํͰ৭ʑͱ஌͓͔ͬͯͳ͍ͱ։ൃ͍ͯ͘͠தͰนʹ౰ͨΔ͜ͱ ΋ଟ͍ͷͰ͸ʹͳ͍͔ͱײ͡Δ

    
 BDUPSJTPMBUFEͷνΣοΫʹΑΔίϯύΠϧΤϥʔͷཧ༝ 
 $IJME5BTLͷ࣮ߦλΠϛϯά͕૝ఆͱҧ͍ͬͯͨ͜ͱͰ༧ظͤ ͵ڍಈΛͯ͠σόοάʹ͕͔͔࣌ؒΔ 
 ϑΣʔζͰಋೖͨ͠΋ͷ͕ϑΣʔζͰಈ͔ͳ͘ͳΔɺͳͲ