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

そろそろSwift Concurrency

そろそろSwift Concurrency

Talk about Swift Concurrency at TechFeed Experts Night

[email protected]

September 07, 2022
Tweet

Other Decks in Programming

Transcript

  1. TIJ[
    5FDI'FFE&YQFSUT/JHIU

    ͦΖͦΖ4XJGU$PODVSSFODZ

    View full-size slide

  2. 4XJGUݴޠΨΠυ೔ຊޠ൛
    TXJGUPSH
    4XJGUʹ͍ͭͯهࡌ
    ໊લTIJ[ ͣ͠

    J04ΤϯδχΞJO෱Ԭ
    !TU[O

    View full-size slide

  3. 4XJGU$PODVSSFODZ
    w 4XJGUͰొ৔ͨ͠ݴޠػೳ
    w ඇಉظॲཧΛಉظॲཧͱಉ͡Α͏ͳܗͰѻ͑Δ "TZODBXBJU

    w ෳ਺ͷඇಉظॲཧΛߏ଄Խͯ͠ಉ࣌ฒྻʹ࣮ߦͰ͖Δ
    4USVDUVSFE$PODVSSFODZ

    w ϚϧνεϨουؒͰͷσʔλڝ߹Λ๷͛Δ "DUPS

    View full-size slide

  4. 4XJGU$PODVSSFODZͷͭͷجຊػೳ
    w "TZODBXBJU
    w 4USVDUVSFEDPODVSSFODZ
    w "DUPS

    View full-size slide

  5. "TZODBXBJU
    "TZODBXBJU

    View full-size slide

  6. "TZODBXBJUͱ͸ʁ
    w ಉ࣌ฒߦॲཧͷϒϩοΫΛߏங͢Δ
    w ϒϩοΫ಺෦ͰॲཧΛதஅͯ͠ผͷඇಉظॲཧΛݺͼग़͢͜ͱ
    ͕Ͱ͖Δ
    w ͦΕ·Ͱͷ࣮ߦεϨουΛҰ౓ख์͠ɺͦͷεϨου͸ଞͷ
    ॲཧΛ࣮ߦͰ͖Δ
    w ݺͼग़ͨ͠ඇಉظॲཧͷ݁ՌΛ଴ػ͔ͯ͠ΒॲཧΛ࠶։͢Δ
    "TZODBXBJU"TZODBXBJUͱ͸ʁ

    View full-size slide

  7. BTZOD
    ݺͼग़͠
    ਤͰݟΔ"TZODBXBJU
    "TZODBXBJU
    εϨου

    View full-size slide

  8. BTZOD
    BXBJU BTZOD
    ݁ՌΛ଴ػ
    ਤͰݟΔ"TZODBXBJU
    "TZODBXBJU

    View full-size slide

  9. ଞͷॲཧΛ࣮ߦͰ͖Δ
    BTZOD
    BXBJU
    தஅ
    BTZOD
    ݁ՌΛ଴ػ
    ਤͰݟΔ"TZODBXBJU
    "TZODBXBJU

    View full-size slide

  10. BTZOD
    BTZOD
    BXBJU ݁ՌΛऔಘ
    BTZOD
    ࠶։
    ਤͰݟΔ"TZODBXBJU
    "TZODBXBJU

    View full-size slide

  11. ࠶։લͱಉ͡εϨουͱ͸ݶΒͳ͍
    BTZOD
    BXBJU
    BTZOD

    ࠶։
    ਤͰݟΔ"TZODBXBJU
    "TZODBXBJU

    View full-size slide

  12. ίʔυͰݟΔ"TZODBXBJU
    "TZODBXBJU
    ίʔϧόοΫܗࣜ

    View full-size slide

  13. ίʔυͰݟΔ"TZODBXBJU
    "TZODBXBJU

    View full-size slide

  14. ίʔυͰݟΔ"TZODBXBJU
    "TZODBXBJU

    View full-size slide

  15. "TZODBXBJU
    ίʔυͰݟΔ"TZODBXBJU

    View full-size slide

  16. ίʔυͰݟΔ"TZODBXBJU
    "TZODBXBJU

    View full-size slide

  17. ίʔυͰݟΔ"TZODBXBJU
    "TZODBXBJU

    View full-size slide

  18. ࣗવͳྲྀΕ
    ίʔυͰݟΔ"TZODBXBJU
    "TZODBXBJU

    View full-size slide

  19. ࣗવͳྲྀΕ
    BTZODɺBXBJU͕ͳ͍ͱίϯύΠϧΤϥʔ
    ίʔυͰݟΔ"TZODBXBJU
    "TZODBXBJU

    View full-size slide

  20. ؔ਺ͷείʔϓΛൈ͚ͨޙʹ࣮ߦ͞ΕΔ
    ࣗવͳྲྀΕ
    BTZODɺBXBJU͕ͳ͍ͱίϯύΠϧΤϥʔ
    ίʔυͰݟΔ"TZODBXBJU
    "TZODBXBJU

    View full-size slide

  21. ؔ਺ͷείʔϓΛൈ͚ͨޙʹ࣮ߦ͞ΕΔ
    ؔ਺ͷείʔϓ಺Ͱ͢΂ͯ׬݁͢Δ
    ࣗવͳྲྀΕ
    BTZODɺBXBJU͕ͳ͍ͱίϯύΠϧΤϥʔ
    ίʔυͰݟΔ"TZODBXBJU
    "TZODBXBJU

    View full-size slide

  22. ؔ਺ͷείʔϓΛൈ͚ͨޙʹ࣮ߦ͞ΕΔ
    ؔ਺ͷείʔϓ಺Ͱ͢΂ͯ׬݁͢Δ
    ࣗવͳྲྀΕ
    BTZODɺBXBJU͕ͳ͍ͱίϯύΠϧΤϥʔ
    ໭Γ஋͸௨ৗͷܕ
    ίʔυͰݟΔ"TZODBXBJU
    "TZODBXBJU

    View full-size slide

  23. 4USVDUVSFE
    DPODVSSFODZ
    4USVDUVSFEDPODVSSFODZ

    View full-size slide

  24. 5BTL
    w 4XJGU$PODVSSFODZͷॲཧͷجຊ୯Ґ
    w 5BTL୯ҐͰ࣮ߦঢ়گ΍ؔ࿈σʔλΛ؅ཧ

    ϩʔΧϧม਺ɺΩϟϯηϧॲཧɺBTZODίʔυͷ։࢝தஅͳͲ

    BTZOD
    BXBJU
    BTZOD
    5BTL
    BTZOD
    BXBJU
    BTZOD
    5BTL
    BTZOD
    BXBJU
    BTZOD
    5BTL
    4USVDUVSFEDPODVSSFODZ5BTL

    View full-size slide

  25. 4USVDUVSFEDPODVSSFODZͱ͸ʁ
    w BTZODBXBJUΛ࢖ͬͯෳ਺ͷॲཧΛಉ࣌ฒྻʹ࣮ߦ͢Δ
    w 5BTLؒͰ֊૚ߏ଄Λߏஙͯ͠ɺඇಉظॲཧͷ଴ػ΍Ωϟϯη
    ϧॲཧͳͲΛ͜ͷ֊૚಺Ͱ͢΂ͯ׬݁ͤ͞Δ
    BTZOD
    5BTL
    BTZOD
    5BTL 5BTL
    4USVDUVSFEDPODVSSFODZ4USVDUVSFEDPODVSSFODZͱ͸ʁ

    View full-size slide

  26. BTZODMFU
    63-4FTTJPOEBUBϝιου
    IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOGPVOEBUJPOVSMTFTTJPOEBUB
    4USVDUVSFEDPODVSSFODZBTZODMFU

    View full-size slide

  27. BTZODMFU
    BTZODMFUͷӈลʹBXBJUΛ෇͚ͳ͍৔߹݁ՌΛ଴ػ͠ͳ͍
    BXBJU
    4USVDUVSFEDPODVSSFODZBTZODMFU

    View full-size slide

  28. BTZODMFU
    4USVDUVSFEDPODVSSFODZBTZODMFU

    View full-size slide

  29. BTZODMFU
    USZBXBJUͰ݁ՌΛ଴ػ
    4USVDUVSFEDPODVSSFODZBTZODMFU

    View full-size slide

  30. BTZODMFU
    BTZODMFUͷݺͼग़͠ݩ਌λεΫ
    BTZODMFU͔Β࡞੒͞ΕͨλεΫࢠλεΫ
    ࢠλεΫ͕શ෦׬ྃ͢Δ·Ͱ਌λεΫ͸׬ྃ͠ͳ͍
    4USVDUVSFEDPODVSSFODZBTZODMFU
    ਌λεΫΛΩϟϯηϧ͢ΔͱࢠλεΫ΋Ωϟϯηϧঢ়ଶʹͳΔ
    ʜͳͲ

    View full-size slide

  31. ֎ଆͷ5BTL͔Βಠཱͨ͠5BTLΛ࡞੒
    6OTUSVDUVSFEDPODVSSFODZ
    w पΓͷ5BTL͔Βಠཱͨ͠5BTLΛੜ੒͢Δ
    w ݁Ռͷ଴ػ΍Ωϟϯηϧ͸खಈͰ࣮ߦ͢Δඞཁ͕͋Δ
    w 5BTLJOJUͱ5BTLEFUBDIFE͕͋Δ ಠཱͷ౓߹͍͕ҟͳΔ

    BTZOD
    5BTL
    BTZOD
    5BTL 5BTL
    4USVDUVSFEDPODVSSFODZ6OTUSVDUVSFEDPODVSSFODZ

    View full-size slide

  32. "DUPSͱ͸ʁ
    w Ұ౓ʹͭͷ5BTLͷΈ͕಺෦ঢ়ଶΛૢ࡞Ͱ͖ΔΑ͏ʹͯ͠ɺෳ਺ε
    Ϩου͔Βͷಉ࣌ಡΈॻ͖ʹΑΔσʔλڝ߹Λ๷͙
    BTZOD
    5BTL
    BDUPS
    5BTL 5BTL
    BTZOD BTZOD
    σʔλڝ߹ෳ਺εϨου͔Βಉ͡σʔλ΁ಡΈॻ͖Λಉ࣌ʹߦͬͨ݁Ռɺෆਖ਼ͳ஋Λऔಘ͠
    ͯ͠·ͬͨΓɺΫϥογϡ͢ΔՄೳੑͷ͋Δঢ়ଶ
    "DUPS"DUPSͱ͸ʁ

    View full-size slide

  33. DMBTTͰσʔλڝ߹͕ൃੜ͢Δ
    4XJGUͷDMBTT͸ࢀরܕ
    ಺෦ঢ়ଶ͸ෳ਺εϨουʹڞ༗͞ΕΔՄೳੑ͕͋Δ
    "DUPSσʔλڝ߹

    View full-size slide

  34. DMBTTͰσʔλڝ߹͕ൃੜ͢Δ
    λΠϛϯά࣍ୈͰظ଴͠ͳ͍݁ՌʹͳΔ
    ग़ྗ݁Ռ








    ˞5BTLEFUBDIFEͰಠཱͨ͠λεΫΛ࡞੒͢Δ
    "DUPSσʔλڝ߹

    View full-size slide

  35. "DUPSͩͱσʔλڝ߹͕ൃੜ͠ͳ͍
    "DUPSσʔλڝ߹

    View full-size slide

  36. "DUPSͩͱσʔλڝ߹͕ൃੜ͠ͳ͍
    ݁Ռ͸ৗʹظ଴௨Γ
    ग़ྗ݁Ռ




    "DUPSσʔλڝ߹

    View full-size slide

  37. "DUPSͷੑ࣭
    ಺෦ঢ়ଶ͸"DUPSͰकΒΕ͍ͯΔ
    📬 🤏



    w Ұ౓ʹҰͭͷλεΫͷΈ࣮ߦ͢Δ
    w "DUPS͸ͦΕͧΕ֎ͷੈք͔Βִ཭͞Ε͍ͯΔ
    "DUPS֎ "DUPS಺
    "DUPS"DUPSͷੑ࣭

    View full-size slide

  38. "DUPSؒͷભҠͷίετ
    "DUPS "DUPS
    w "DUPSؒͷભҠʹ͸ίετ͕͔͔Δ
    "DUPS஫ҙ఺
    💸

    View full-size slide

  39. 7JFX͸.BJO"DUPS
    BDUPS
    .BJO"DUPS
    7JFX 7JFX.PEFM

    w 7JFX.PEFMΛBDUPSʹ͢Δͱ"DUPSؒͰͷεΠον͕ൃੜ͢Δ
    "DUPS஫ҙ఺
    💸

    View full-size slide

  40. 7JFX.PEFMΛ.BJO"DUPSʹ͢Δ
    w ಉ͡"DUPS಺ͷॲཧʹͳΔ
    !.BJO"DUPSDMBTT
    .BJO"DUPS
    7JFX 7JFX.PEFM

    "DUPS஫ҙ఺
    🪙

    View full-size slide

  41. 4XJGU$PODVSSFODZ
    w "TZODBXBJU
    w 4USVDUVSFEDPODVSSFODZ
    w "DUPS

    View full-size slide

  42. ͋Γ͕ͱ͏͍͟͝·ͨ͠

    View full-size slide

  43. ೖ໳ʹ͓͢͢Ί88%$ηογϣϯ
    w 4XJGU$PODVSSFODZղઆηογϣϯ

    .FFUBTZODBXBJUJO4XJGU🌟Ұ൪࠷ॳʹݟΔͷʹ͓͢͢Ί

    &YQMPSFTUSVDUVSFEDPODVSSFODZJO4XJGU

    1SPUFDUNVUBCMFTUBUFXJUI4XJGUBDUPST
    w ΑΓ಺෦ͷ࢓૊ΈΛ஌Δηογϣϯ

    4XJGUDPODVSSFODZ#FIJOEUIFTDFOFT
    w ҰॹʹαϯϓϧΛϦϑΝΫλϦϯά͠ͳ͕Βֶ΂Δηογϣϯ

    4XJGUDPODVSSFODZ6QEBUFBTBNQMFBQQ🌟طଘίʔυ͔Βͷม׵ΛҰาҰาֶ΂Δ
    w ଞͷ'SBNFXPSLͱͷ࿈ܞํ๏Λ஌Δηογϣϯ

    #SJOH$PSF%BUBDPODVSSFODZUP4XJGUBOE4XJGU6*

    %JTDPWFSDPODVSSFODZJO4XJGU6*

    .BLFCMB[JOHGBTUMJTUTBOEDPMMFDUJPOWJFXT 6**NBHFͷ/FX"1*

    View full-size slide