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

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

notoroid
August 04, 2021

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

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

notoroid

August 04, 2021
Tweet

More Decks by notoroid

Other Decks in Programming

Transcript

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  15. BDUPS
    w ෳ਺ͷεϨου͔Βݺͼग़͞ΕΔ஋Λอޢ͢Δ࢓૊ΈΛDMBTTϥ
    ΠΫͳఆٛͰهड़Ͱ͖Δ
    w ϓϩύςΟ͸ෳ਺͔Βͷ஋มߋͷࡍʹBXBJUͰ଴डՄೳ
    w ϝιουΛఆٛ͢Δͱͦͷϝιου͕ݺͼऴΘΔ·Ͱ֎෦͔Βม
    ߋ͕ՃΘΒͳ͍
    w ஋ͷڝ߹Λ͚͞ΔͨΊ಺෦తʹ͸4JHOBMɺ4FNBQIPSFͳͲΞΫ
    ηε੍ޚػೳΛ࢖͍ͬͯΔ͕4XJGUίʔυهड़ऀଆ͔Β͸Ӆṭ͞
    Ε͍ͯΔɻ

    View full-size slide

  16. ߏ଄Խ͞Εͨಉظॲཧ
    w "TZODBXBJUΛ֊૚తʹݺͼग़͠ͱݺͼग़͠֊૚Λߟྀͨ͠ಉظ
    ॲཧΛ࣮ݱͰ͖Δ
    w 4XJGUΑΓલ͸ಠཱͨ͠ಉظॲཧΛ·ͱΊΔͳͲ࣮ͯ͠ݱͰ
    ͖ͨ͜ͱ͕4XJGU͔Β͸σϑΥϧτͷಉظॲཧѻ͍ͱͳͬͨ
    w ͜Ε·Ͱͷಉظॲཧ͸Φϓγϣϯѻ͍ͱͳΓಠཱͨ͠ಉظॲཧͱ
    ໋໊
    w ಠཱͨ͠ಉظॲཧ͸Φϓγϣϯѻ͍ʹͳͬͨ෼ɺBTZODBXBJU
    ΑΓ͸໌ࣔతʹݺͼग़͠ඞཁ

    View full-size slide

  17. !.BJO"DUPS
    w "DUPS͸ෳ਺ΞΫηε͕͋ͬͨ৔߹ͷ஋Λอޢ͢Δ࢓૊ΈΛఏڙ
    ͢Δ͚͕ͩͩͬͨ
    w !.BJO"DUPS͸଴डޙʹඞͣϝΠϯεϨου͔Βݺͼग़͞ΕΔอ
    ূ͢ΔͨΊͷ࢓૊Έ
    w 4XJGU"UUSJCVUFTͳͷͰ4XJGUͷ࢓༷͔Β͸एׯ֎ΕΔ
    w 4%,Ͱ͸ϝΠϯεϨουPSϝΠϯεϨουҎ֎ݺͼग़͔͠໌ࣔͰ
    ͖͍ͯͳ͔ͬͨ΋ͷ ؔ਺ɺΫϥεͷϓϩύςΟͳͲ
    ͕໌ࣔతʹ
    ͳͬͨ

    View full-size slide

  18. ୺తʹ͍͏ͱʜ
    w ৽͍͠ϘΩϟϒϥϦʔͱͯ͠BTZODBXBJUΛಋೖ͢Δ͜ͱͰॲཧ଴
    ͪͷهड़Λ୹͘هड़Ͱ͖ΔΑ͏ʹͳͬͨɻͨͩ͠ඇಉظʹͨ͠ࡍʹى
    ͖Δτϥϒϧ͸ίʔυهड़ऀଆͷ੹೚Ͱ͋Δ͜ͱ͸มԽແ͠
    w ฒྻಉظͷฒྻੑͱߏ଄Խ͞ΕͨฒྻॲཧʹΑΓฒྻॲཧʹίʔυత
    ͳॊೈੑ͕ੜ·Ε͍ͯΔɻͦΕΛ࣮ݱ͢ΔͨΊ࣮ݱ͢ΔͨΊBTZOD
    BXBJUͰεϨουΛίʔυهड़ऀ͔ΒӅṭ͍ͯ͠ΔΑ͏ͳ΋ͷ
    w 6*ύʔπͳͲϝΠϯεϨουݺͼग़͠Λอূ͢ΔͨΊͷهड़ͱͯ͠
    !.BJO"DUPS͕௥Ճ͞Εͨɻίʔυهड़ऀ͸ݺͼग़͠ݩͷεϨουʹ
    ஫ҙΛ޲͚Δඞཁ͕͕͋ͬͨݴޠϨϕϧͰ҆શͳݺͼग़͕͠อূ͞Ε
    ͨ

    View full-size slide

  19. ϓϨθϯςʔγϣϯ঺հ

    View full-size slide

  20. w .FFUBTZODBXBJUJO4XJGU
    w .FFU"TZOD4FRVFODF
    w &YQMPSFTUSVDUVSFE
    DPODVSSFODZJO4XJGU
    w 1SPUFDUNVUBCMFTUBUFXJUI
    4XJGUBDUPST
    w %JTDPWFSDPODVSSFODZJO
    4XJGU6*
    ϓϨθϯςʔγϣϯ঺հ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  23. &YQMPSFTUSVDUVSFE
    DPODVSSFODZJO4XJGU
    IUUQTEFWFMPQFSBQQMFDPNWJEFPT
    QMBZXXED
    w "TZOD͕෇Ճ͞Εͨݺͼग़͠
    ಺෦ͰBXBJUΛ࢖͏͜ͱ͕Ͱ
    ͖Δ఺Λઆ໌ͨ͠ϓϨθϯς
    ʔγϣϯɻ
    w Τϥʔ͕͋ͬͨ৔߹ʹFSSPS
    ΛUISPXͨ͠৔߹ͷڍಈʹͭ
    ͍ͯͷݴٴ͋Γɻ
    w ಠཱͨ͠ඇಉظॲཧʹ͍ͭͯ
    ΋ຊϓϨθϯςʔγϣϯͰઆ
    ໌͍ͯ͠Δɻ

    View full-size slide

  24. 1SPUFDUNVUBCMFTUBUF
    XJUI4XJGUBDUPST
    IUUQTEFWFMPQFSBQQMFDPNWJEFPT
    QMBZXXED
    w BDUPSͱ!.BJO"DUPSͷઆ

    w ಺༰తʹ͸!.BJO"DUPSΛ
    આ໌͢ΔͨΊͷBDUPSΛઆ
    ໌͢Δͱ͍ͬͨ࿩

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  27. ίϯγϡʔϚʔιϑτ΢ΣΞʹಉظॲཧ͕ಋೖ͞Ε࢛ͯ൒ੈلᶄ
    w ΞϓϦͰ͸"QQMF͕Ͱ$FOUSBM%JTQBUDI2VFVFͰCMPDLߏจͱɺ
    ม਺ͷΩϟϓνϟΛಋೖ
    w ˡίϯύΠϥʹϝεΛೖΕΔܾஅ͔Β৽ݴޠ4XJGU͕஀ੜ
    w ฒߦੑʹ͍ͭͯͷٞ࿦͕׆ൃʹͳͬͨͷ͸/PEF+4 αʔόʔαΠ
    υ+BWB4DSJQU
    ͷBTZODBXBJU
    w ˡฒߦੑΛهड़ํ๏ʹܾண͢Δ΋ϚϧνεϨουΛѻ͏ݴޠͰͷ
    ಋೖ͸ݕ౼தͩͬͨ

    View full-size slide

  28. ݸਓత4XJGUฒߦੑݟղ

    View full-size slide

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

    View full-size slide