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

Swift 並行性(Concurrency)を読み解く - WWDC21

Swift 並行性(Concurrency)を読み解く - WWDC21

Swift Concurrency関連プレゼンテーションガイド

0fb0b8c6eecbc8e0a3981501f6a6fea6?s=128

notoroid

August 04, 2021
Tweet

Transcript

  1. 4XJGUฒߦੑ $PODVSSFODZ ΛಡΈղ͘ 88%$ 4XJGU$PODVSSFODZؔ࿈ϓϨθϯΨΠυ

  2. ࢀߟࢿྉ"QQMF%FWFMPQFS IUUQTBQQTBQQMFDPNKQBQQBQQMFEFWFMPQFSJE 88%$಺༰͸ॱ࣍೔ຊޠରԠ͞Ε͍ͯ͘

  3. 88%$͔Βϲ݄ɻ 4XJGUݴޠͷ໨ۄͷBXBJUBTZOD BDUPS͕ൃද͞Ε·ͨ͠

  4. ͕ɺϲ݄ܦͬͯ΋৽࢓ ༷ʹશ͘׳Εͳ͍ʂ

  5. 88%$ͷؔ࿈͢ΔϓϨθϯ ࢿྉ͸໨Λͱ͓ͨ͠ͷͰ঺հɻ

  6. 88%$ͰԿ͕͓͖ͨͷ͔ 4XJGU ͍ͭʹBTZODBXBJU͕ಋೖ͞Ε·ͨ͠ɻBTZODBXBJU ͚ͩͰͳ͘ɺBDUPS!.BJO"DUPS͕ಋೖɻ

  7. 88%$ͰԿ͕͓͖ͨͷ͔ 4XJGU ͍ͭʹBTZODBXBJU͕ಋೖ͞Ε·ͨ͠ɻBTZODBXBJU ͚ͩͰͳ͘ɺBDUPS!.BJO"DUPS͕ಋೖɻ BTZODBXBJUʹ͍ͭͯ͸88%$ҎલΑΓݴޠ࢓༷ ͱͯ͠ఏҊ͞Ε͓ͯΓɺ৽ٕज़ʹΊ͟ͱ͍ෳ਺ͷ։ൃ ऀ༷ΑΓهࣄ͕ެ։͞Ε͍ͯΔɻ

  8. 1SPQPTBMʹ͸ࡌ ͍ͬͯͳ͍4XJGU ͷBTZODBXBJU ͕ૉ੖Β͍͠ͱࢥ ͏ཧ࿦తഎܠ IUUQTRJJUBDPN LPIFSJUFNT CFBFD 

  9. ಡΈ෺ͱͯ͠͸໘ന͍ɺ ໘ന͍͕ผʹٕज़ͰΩϟοΩϟͨ͠ ͍Θ͚Ͱͳ͍ͱ͍͏ͷ͕ຊԻɻ

  10. &$."4DSJQUͰઌΜͯ͡ಋೖ͞Εͯ ͍ͨػೳ͕4XJGUʹ΍͖ͬͯͨ͋Γ͕ ͕ͨΔؾ΋ແ͔ͬͨΓ͢Δɻ

  11. ৽͍͠ݴޠ࢓༷͕ಋೖ͢Δ ඞཁ͕͋Δ఺ ඞવੑ ʹೲಘ͠ɺ ଉΛు༷͘ʹࣗવʹར༻Ͱ͖Δ͜ͱ͕ཧ૝Ͱ͸

  12. ͱ͍͏ཧ೦ͷ΋ͱɺBTZODBXBJUBDUPSपΓ͕ಋ ೖ͞Εͨࡍͷ4XJGUݴޠʹ͓͚ΔฒߦੑΛѻ͏্Ͱ ͷϨΪϡϨʔγϣϯมߋʹ͍ͭͯղܾʹઆ໌͢Δɻ

  13. 88%$ͷ 4XJGUʹ͓͚Δฒߦੑ ֓ཁ

  14. BTZODBXBJU w "TZODඇಉظΛࣔ͢म০ࢠͰ w BTZOD͕෇༩͞ΕΔͱBXBJUΛ࢖ͬͯॲཧऴྃ·Ͱ଴डঢ়ଶʹ͢ Δ͜ͱΛӅṭͰ͖Δ w NBD04J1IPOFͰͷϚϧνεϨου্ͷॲཧ͕࣮ࡍͲ͏ͳͬͯ ͍Δ͔͸4XJGUίʔυهड़ऀଆ͔Β͸Ӆṭ͞Ε͍ͯΔ

  15. BDUPS w ෳ਺ͷεϨου͔Βݺͼग़͞ΕΔ஋Λอޢ͢Δ࢓૊ΈΛDMBTTϥ ΠΫͳఆٛͰهड़Ͱ͖Δ w ϓϩύςΟ͸ෳ਺͔Βͷ஋มߋͷࡍʹBXBJUͰ଴डՄೳ w ϝιουΛఆٛ͢Δͱͦͷϝιου͕ݺͼऴΘΔ·Ͱ֎෦͔Βม ߋ͕ՃΘΒͳ͍ w

    ஋ͷڝ߹Λ͚͞ΔͨΊ಺෦తʹ͸4JHOBMɺ4FNBQIPSFͳͲΞΫ ηε੍ޚػೳΛ࢖͍ͬͯΔ͕4XJGUίʔυهड़ऀଆ͔Β͸Ӆṭ͞ Ε͍ͯΔɻ
  16. ߏ଄Խ͞Εͨಉظॲཧ w "TZODBXBJUΛ֊૚తʹݺͼग़͠ͱݺͼग़͠֊૚Λߟྀͨ͠ಉظ ॲཧΛ࣮ݱͰ͖Δ w 4XJGUΑΓલ͸ಠཱͨ͠ಉظॲཧΛ·ͱΊΔͳͲ࣮ͯ͠ݱͰ ͖ͨ͜ͱ͕4XJGU͔Β͸σϑΥϧτͷಉظॲཧѻ͍ͱͳͬͨ w ͜Ε·Ͱͷಉظॲཧ͸Φϓγϣϯѻ͍ͱͳΓಠཱͨ͠ಉظॲཧͱ ໋໊

    w ಠཱͨ͠ಉظॲཧ͸Φϓγϣϯѻ͍ʹͳͬͨ෼ɺBTZODBXBJU ΑΓ͸໌ࣔతʹݺͼग़͠ඞཁ
  17. !.BJO"DUPS w "DUPS͸ෳ਺ΞΫηε͕͋ͬͨ৔߹ͷ஋Λอޢ͢Δ࢓૊ΈΛఏڙ ͢Δ͚͕ͩͩͬͨ w !.BJO"DUPS͸଴डޙʹඞͣϝΠϯεϨου͔Βݺͼग़͞ΕΔอ ূ͢ΔͨΊͷ࢓૊Έ w 4XJGU"UUSJCVUFTͳͷͰ4XJGUͷ࢓༷͔Β͸एׯ֎ΕΔ w

    4%,Ͱ͸ϝΠϯεϨουPSϝΠϯεϨουҎ֎ݺͼग़͔͠໌ࣔͰ ͖͍ͯͳ͔ͬͨ΋ͷ ؔ਺ɺΫϥεͷϓϩύςΟͳͲ ͕໌ࣔతʹ ͳͬͨ
  18. ୺తʹ͍͏ͱʜ w ৽͍͠ϘΩϟϒϥϦʔͱͯ͠BTZODBXBJUΛಋೖ͢Δ͜ͱͰॲཧ଴ ͪͷهड़Λ୹͘هड़Ͱ͖ΔΑ͏ʹͳͬͨɻͨͩ͠ඇಉظʹͨ͠ࡍʹى ͖Δτϥϒϧ͸ίʔυهड़ऀଆͷ੹೚Ͱ͋Δ͜ͱ͸มԽແ͠ w ฒྻಉظͷฒྻੑͱߏ଄Խ͞ΕͨฒྻॲཧʹΑΓฒྻॲཧʹίʔυత ͳॊೈੑ͕ੜ·Ε͍ͯΔɻͦΕΛ࣮ݱ͢ΔͨΊ࣮ݱ͢ΔͨΊBTZOD BXBJUͰεϨουΛίʔυهड़ऀ͔ΒӅṭ͍ͯ͠ΔΑ͏ͳ΋ͷ w

    6*ύʔπͳͲϝΠϯεϨουݺͼग़͠Λอূ͢ΔͨΊͷهड़ͱͯ͠ !.BJO"DUPS͕௥Ճ͞Εͨɻίʔυهड़ऀ͸ݺͼग़͠ݩͷεϨουʹ ஫ҙΛ޲͚Δඞཁ͕͕͋ͬͨݴޠϨϕϧͰ҆શͳݺͼग़͕͠อূ͞Ε ͨ
  19. ϓϨθϯςʔγϣϯ঺հ

  20. w .FFUBTZODBXBJUJO4XJGU w .FFU"TZOD4FRVFODF w &YQMPSFTUSVDUVSFE DPODVSSFODZJO4XJGU w 1SPUFDUNVUBCMFTUBUFXJUI 4XJGUBDUPST

    w %JTDPWFSDPODVSSFODZJO 4XJGU6* ϓϨθϯςʔγϣϯ঺հ
  21. .FFUBTZODBXBJUJO 4XJGU IUUQTEFWFMPQFSBQQMFDPNWJEFPT QMBZXXED w BTZODΛ࢖͏ؔ਺ͷఆٛํ ๏ͱɺBXBJUͷ࢖͍ํʹͭ ͍ͯͷϓϨθϯςʔγϣ ϯɻ

  22. .FFU"TZOD4FRVFODF IUUQTEFWFMPQFSBQQMFDPNWJEFPT QMBZXXED w BTZOD͕෇Ճ͞Εͨݺͼग़ ͠Λ഑ྻԽ͢ΔͱBXBJU͠ ͨࡍʹ΋ฒߦͯ͠ݺͼग़͞ ΕΔ͜ͱʹ͍ͭͯͷϓϨθ ϯςʔγϣϯɻ

  23. &YQMPSFTUSVDUVSFE DPODVSSFODZJO4XJGU IUUQTEFWFMPQFSBQQMFDPNWJEFPT QMBZXXED w "TZOD͕෇Ճ͞Εͨݺͼग़͠ ಺෦ͰBXBJUΛ࢖͏͜ͱ͕Ͱ ͖Δ఺Λઆ໌ͨ͠ϓϨθϯς ʔγϣϯɻ w

    Τϥʔ͕͋ͬͨ৔߹ʹFSSPS ΛUISPXͨ͠৔߹ͷڍಈʹͭ ͍ͯͷݴٴ͋Γɻ w ಠཱͨ͠ඇಉظॲཧʹ͍ͭͯ ΋ຊϓϨθϯςʔγϣϯͰઆ ໌͍ͯ͠Δɻ
  24. 1SPUFDUNVUBCMFTUBUF XJUI4XJGUBDUPST IUUQTEFWFMPQFSBQQMFDPNWJEFPT QMBZXXED w BDUPSͱ!.BJO"DUPSͷઆ ໌ w ಺༰తʹ͸!.BJO"DUPSΛ આ໌͢ΔͨΊͷBDUPSΛઆ

    ໌͢Δͱ͍ͬͨ࿩
  25. %JTDPWFSDPODVSSFODZJO 4XJGU6* IUUQTEFWFMPQFSBQQMFDPNWJEFPT QMBZXXED w BTZODBXBJUBDUPS͕6* पΓͷίʔσΟϯάελΠ ϧΛม͑Δ͜ͱ͸͔͕֬ͩ Ұ൪ԸܙΛड͚͍ͯΔͷ͸ 4XJGU6*ͰΔ͜ͱΛࣔ͢ϓ

    Ϩθϯςʔγϣϯɻ
  26. ࡶ؍

  27. ίϯγϡʔϚʔιϑτ΢ΣΞʹಉظॲཧ͕ಋೖ͞Ε࢛ͯ൒ੈلᶃ w 8JOEPXTͷ͜Ζ͸ϚʔέςΟϯάతʹػೳ͕௥Ճ͞Ε։ൃऀ ΁ͷαϙʔτ͸ͳ͔ͬͨ w ˡ$$ ݴޠͷ؀ڥ͕ϚϧνεϨουΛߟྀ͠ͳ͍ظ͕ؒଓ͍ ͨ w ฒߦੑʹΑΔੑೳʹ͍ͭͯ͸+BWB7.͕αʔόʔαΠυͰূ໌͠

    ͍ͯͨ w ˡධՁ͞Εͨͷ͸+BWB4DSJQUͷϚϧνεϨουੑೳͩͬͨ w +BWB7.ݴޠͱͯ͠4DBMB͕ొ৔
  28. ίϯγϡʔϚʔιϑτ΢ΣΞʹಉظॲཧ͕ಋೖ͞Ε࢛ͯ൒ੈلᶄ w ΞϓϦͰ͸"QQMF͕Ͱ$FOUSBM%JTQBUDI2VFVFͰCMPDLߏจͱɺ ม਺ͷΩϟϓνϟΛಋೖ w ˡίϯύΠϥʹϝεΛೖΕΔܾஅ͔Β৽ݴޠ4XJGU͕஀ੜ w ฒߦੑʹ͍ͭͯͷٞ࿦͕׆ൃʹͳͬͨͷ͸/PEF+4 αʔόʔαΠ υ+BWB4DSJQU

    ͷBTZODBXBJU w ˡฒߦੑΛهड़ํ๏ʹܾண͢Δ΋ϚϧνεϨουΛѻ͏ݴޠͰͷ ಋೖ͸ݕ౼தͩͬͨ
  29. ݸਓత4XJGUฒߦੑݟղ

  30. 4XJGUݴޠͷ$PODVSSFODZͰ೥લʹෆ޾ ʹ΋ίϯγϡʔϚʔιϑτʹಋೖ͞Εͨಉ ظॲཧͷه๏ʹҰఆͷܾண͕͍ͭͨͷͰ͸