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

Swift Concurrencyを導入するにあたって決めたこと

Swift Concurrencyを導入するにあたって決めたこと

hicka04

March 15, 2022
Tweet

More Decks by hicka04

Other Decks in Programming

Transcript

  1. 4XJGU$PODVSSFODZΛ
    ಋೖ͢Δʹܾ͋ͨͬͯΊͨ͜ͱ
    2022/03/15
    佐藤 光

    View full-size slide

  2. mixi, Inc.
    ࣗݾ঺հ
    ˔ ࠤ౻ ޫ !IJDLB

    ˔ גࣜձࣾϛΫγΟ ΈͯͶࣄۀ෦ ϓϩμΫτ։ൃάϧʔϓ
    ˓ த్ೖࣾ
    ˔ ޷͖ͳ΋ͷ
    ˓ ϥʔϝϯ
    ˓ ϙέϞϯ

    View full-size slide

  3. mixi, Inc.
    ΞδΣϯμ
    ˔ ʮՈ଒ΞϧόϜ ΈͯͶʯʹ͍ͭͯ
    ˔ 4XJGU$PODVSSFODZʹ͍ͭͯ
    ˔ ࠾༻͍ͯ͠ΔΞʔΩςΫνϟʹ͍ͭͯ
    ˔ 4XJGU$PODVSSFODZΛಋೖ͢Δʹܾ͋ͨͬͯΊͨ͜ͱ
    ˔ ·ͱΊ

    View full-size slide

  4. ʮՈ଒ΞϧόϜ ΈͯͶʯʹ͍ͭͯ

    View full-size slide

  5. mixi, Inc.
    ʮՈ଒ΞϧόϜ ΈͯͶʯʹ͍ͭͯ
    ˔ Ո଒ͰࢠڙͷࣸਅΛ؆୯ʹڞ༗Ͱ͖ΔαʔϏε
    ˔ ʮੈքதͷՈ଒ͷz͜͜ΖͷΠϯϑϥzΛ࡞Δʯ
    Λϛογϣϯʹܝ͛ɺݱࡏݴޠରԠ
    ˔ ҎԼʮΈͯͶʯͱॻ͘

    View full-size slide

  6. 4XJGU$PODVSSFODZʹ͍ͭͯ

    View full-size slide

  7. mixi, Inc.
    4XJGU$PODVSSFODZʹ͍ͭͯ
    ˔ 4XJGU͔Βݴޠػೳʹ౥ࡌ͞ΕͨฒߦॲཧͷͨΊͷϑϨʔϜϫʔΫ
    ˔ ൃද౰ॳ͸J04Ҏ্͔͠࢖͑ͳ͔ͬͨ
    ˔ 9DPEF͔ΒJ04Ͱ΋࢖͑ΔΑ͏ʹόοΫϙʔτ࣮૷͕͞Εͨ
    ˓ ˢΛ͖͔͚ͬʹಋೖݕ౼Λ։࢝

    View full-size slide

  8. mixi, Inc.
    4XJGU$PODVSSFODZʹ͍ͭͯ BTZODBXBJU

    ˔ BTZOD ΩʔϫʔυΛ͚ͭΔ͜ͱͰඇಉظॲཧͰ͋Δ͜ͱΛϚʔΫͰ͖Δ
    BXBJUΩʔϫʔυΛ͚ͭͯݺͼग़͢
    ˔ BTZOD Ωʔϫʔυ͕͍͍ͭͯΔϝιου΍ϓϩύςΟΛݺͼग़ͨ͢Ίͷ৚݅
    ˓ BTZODΩʔϫʔυ͕͍͍ͭͯΔϝιου΍ϓϩύςΟ͔Βݺͼग़͢
    ˓ 5BTL ʹ౉͢Ϋϩʔδϟ಺͔Βݺͼग़͢

    View full-size slide

  9. mixi, Inc.
    4XJGU$PODVSSFODZʹ͍ͭͯ BTZODBXBJU

    Ϋϩʔδϟ
    IUUQTEPDTTXJGUPSHTXJGUCPPL-BOHVBHF(VJEF$PODVSSFODZIUNM

    View full-size slide

  10. mixi, Inc.
    4XJGU$PODVSSFODZʹ͍ͭͯ BTZODBXBJU

    BTZODBXBJU
    IUUQTEPDTTXJGUPSHTXJGUCPPL-BOHVBHF(VJEF$PODVSSFODZIUNM

    View full-size slide

  11. mixi, Inc.
    4XJGU$PODVSSFODZʹ͍ͭͯ BDUPS

    ˔ ෳ਺εϨου͔ΒಡΈॻ͖ͨ͠ͱ͖ͷσʔλڝ߹Λ๷͙
    ˓ ಡΈॻ͖ཁٻ͕Ωϡʔʹੵ·Εɺॱ൪ʹॲཧ͞ΕΔ
    ˓ BDUPSΠϯελϯε͝ͱʹΩϡʔ͕࡞ΒΕΔ
    ˔ HMPCBM"DUPS
    ˓ ಡΈॻ͖ཁٻͷΩϡʔΛෳ਺ͷΠϯελϯεͰڞ༗͢Δ
    ˔ .BJO"DUPS
    ˓ ಡΈॻ͖ཁٻΛϝΠϯΩϡʔʹੵΜͰ͘ΕΔHMPCBM"DUPS
    ˓ දࣔσʔλΛ؅ཧ͢ΔΫϥεʹΛ͚ͭΔͱɺϝΠϯεϨου΁ͷ੾Γସ͑๨ΕʹΑΔΫϥογϡΛ๷͛Δ

    View full-size slide

  12. mixi, Inc.
    4XJGU$PODVSSFODZʹ͍ͭͯ BDUPS

    View full-size slide

  13. ࠾༻͍ͯ͠Δ
    ΞʔΩςΫνϟʹ͍ͭͯ

    View full-size slide

  14. mixi, Inc.
    ࠾༻͍ͯ͠ΔΞʔΩςΫνϟʹ͍ͭͯ
    ˔ ΞʔΩςΫνϟύλʔϯ
    ˓ $MFBO"SDIJUFDUVSF
    ˓ .71 1BTTJWF7JFX

    ˔ ඇಉظॲཧ
    ˓ 3Y4XJGU
    ˓ Ϋϩʔδϟ
    IUUQTNJYJEFWFMPQFSTNJYJDPKQNJUFOFJPTDMFBOBSDIJUFDUVSFEE

    View full-size slide

  15. 4XJGU$PODVSSFODZΛ
    ಋೖ͢Δʹܾ͋ͨͬͯΊͨ͜ͱ

    View full-size slide

  16. mixi, Inc.
    ܾΊͨ͜ͱ σʔλ૚ 3FNPUF

    ˔ "MBNPGJSF
    Λར༻த
    ˓ "MBNPGJSFΛ4XJGU$PODVSSFODZରԠόʔδϣϯ
    ·Ͱ্͛Δ
    ˓ ࣗ෼ͰFYUFOTJPOϝιουΛੜ΍͢
    ˔ ݱঢ়͸ޙऀΛ࠾༻
    ˓ "MBNPGJSFͷϝδϟʔόʔδϣϯΞοϓ଴ͪͰ4XJGU$PODVSSFODZͷಋೖ͕Ͱ͖ͳ͍ࣄଶΛආ͚Δ
    ˓ όʔδϣϯΞοϓ׬ྃ࣍ୈɺॱ࣍FYUFOTJPOϝιουͷར༻Λ΍Ί͍ͯ͘
    IUUQTHJUIVCDPN"MBNPGJSF"MBNPGJSFSFMFBTFT

    View full-size slide

  17. mixi, Inc.
    ܾΊͨ͜ͱ σʔλ૚ 3FNPUF

    IUUQTDPDLTDPNCIBUFOBCMPHDPNFOUSZ

    View full-size slide

  18. mixi, Inc.
    ܾΊͨ͜ͱ σʔλ૚ 3FNPUF

    View full-size slide

  19. mixi, Inc.
    ܾΊͨ͜ͱ σʔλ૚ -PDBM

    ˔ ϩʔΧϧͷσʔλಡΈॻ͖͸ɺओʹ 3FBMN PS6TFS%FGBVMUT
    ˔ 3FBMNͷެࣜυΩϡϝϯτͷ 5ISFBEJOHͷϖʔδ͔Βൈਮ
    ˓ %PObUMPDLUPSFBE ಡΈࠐΈΛϩοΫ͠ͳ͍Ͱ

    ˓ "WPJEXSJUFTPOUIF6*UISFBEJGZPVXSJUFPOBCBDLHSPVOEUISFBE 6*εϨουͰॻ͖ࠐΈ͠ͳ͍Ͱ

    ˔ ಛఆͷεϨου ಛʹ6*εϨου
    Λ઎༗͢ΔͱΞϓϦύϑΥʔϚϯεʹେ͖ͳӨڹ͕ͰΔ
    ˓ Ξοϓϩʔυͨ͠ϝσΟΞͷΩϟογϡ౳Ͱར༻͍ͯ͠Δ
    ˓ ສ୯ҐͰΞοϓϩʔυ͍ͯ͠ΔϢʔβʔ΋͍Δ
    ˔ બ୒ࢶ
    ˓ HMPCBM"DUPSΛ࢖͏ ಛఆͷεϨουΛ઎༗ͯ͠͠·͍΍͘͢ͳΔ
    ˓ XJUI$IFDLFE 5ISPXJOH
    $POUJOVBUJPOº %JTQBUDI2VFVFΛ࢖͏ ($%୤٫͍ͨ͠
    ˓ 5BTLEFUBDIFEΛ࢖͏ IUUQTEPDTNPOHPECDPNSFBMNTELTXJGUBEWBODFEHVJEFTUISFBEJOH

    View full-size slide

  20. mixi, Inc.
    ܾΊͨ͜ͱ σʔλ૚ -PDBM

    ˔ 5BTLEFUBDIFEΛ࢖͏
    ˓ ಛఆͷεϨουΛ઎༗ͮ͠Β͍
    ˓ 4XJGU$PODVSSFODZͷػೳ͚ͩͰ࣮ݱͰ͖Δ
    ˔ ࣗ෼ͰΩϟϯηϧॲཧΛॻ͘ඞཁ͕͋Δ
    ˓ 3FBMNʹಡΈॻ͖ΛΩϟϯηϧ͢ΔΠϯλʔϑΣΠε͕ͳ͍ͨΊߟྀ֎
    ˔ ࢖͏ଆͰγϯϓϧʹॻ͚ΔΑ͏ʹQSPUPDPMΛ༻ҙ
    ˓ 3FBMNΞΫηε͢Δ֤-PDBM%BUB4PVSDF͕४ڌͯ͠࢖͏
    IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOTXJGUUBTLEFUBDIFE

    View full-size slide

  21. mixi, Inc.
    ܾΊͨ͜ͱ σʔλ૚ -PDBM

    View full-size slide

  22. mixi, Inc.
    ܾΊͨ͜ͱ σʔλ૚ -PDBM

    View full-size slide

  23. mixi, Inc.
    ܾΊͨ͜ͱ r υϝΠϯ૚
    ˔ 6TF$BTFʹੜ΍͢ϝιουʹ BTZODΩʔϫʔυΛ෇༩͢Δ
    ˔ ΈͯͶʹ͓͍ͯ6TF$BTF͸ɺσʔλ૚ͷϝιουΛͲͷΑ͏ʹݺͿ͔͕੹຿ʹͳΔ͜ͱ͕ଟ͍
    ˓ σʔλ૚ʹ BTZODϝιουΛੜ΍͢
    ˓ σʔλ૚ͷ BTZODϝιουΛͦͷ··ݺͿ

    View full-size slide

  24. mixi, Inc.
    ܾΊͨ͜ͱ r ϓϨθϯςʔγϣϯ૚
    Ͳ͜ʹ !.BJO"DUPSΛ͚ͭΔ͔
    ˔ 7JFX7JFX$POUSPMMFSͷΈ
    ˔ 1SFTFOUFSͰ͸ঢ়ଶ؅ཧΛ͍ͯ͠ͳ͍ͨΊݱঢ়͸ෆཁͱ൑அ
    Ͳ͜Ͱ 5BTLΛੜ੒͢Δ͔
    ˔ 7JFX7JFX$POUSPMMFSͰੜ੒
    ˔ 1SFTFOUFS͕7JFXʹରͯ͠ެ։͢Δϝιουʹ BTZODΩʔϫʔυΛ͚ͭΔ
    Ͳ͜·ͰΩϟϯηϧॲཧΛؤுΔ͔
    ˔ Ͳ͏ͯ͠΋Ωϟϯηϧ͍ͨ͠ͱ͖ ΩϟϯηϧϘλϯΛஔ͍ͯΔͳͲ
    Ҏ֎͸ؤுΒͳ͍
    ˔ 5BTLʹTFMGΛΩϟϓνϟͤ͞Δͱɺඇಉظॲཧ͕ऴΘΔ·ͰࢀরΧ΢ϯτ͕ݮΒͣϝϞϦϦʔΫʹͳΔ
    ˓ ແݶϧʔϓͯ͠ͳ͚Ε͹͍͔ͭ͸ऴΘͬͯ։์͞ΕΔ
    ˓ ίϯύΠϥͰ๷͙͜ͱ͕೉͍ͨ͠ΊϨϏϡʔίετ্͕͕Δ

    View full-size slide

  25. mixi, Inc.
    ܾΊͨ͜ͱ r ςετίʔυ
    ςεςΟϯάϑϨʔϜϫʔΫ
    ˔ ݱঢ়9$5FTUPS2VDJL
    ˔ 2VJDL͸ݱࡏɺ4XJGU$PODVSSFODZະରԠ
    ˔ ࠓޙ͸9$5FTUΛ࢖͏
    ϞοΫ
    ˔ ݱঢ়4PVSDFSZ
    ˔ બ୒ࢶ
    ˓ .PDLPMPʹมߋ πʔϧΛ૿΍͞ͳ͍ͨΊ

    ˓ 4PVSDFSZΛ4XJGU$PODVSSFODZରԠόʔδϣϯʹΞοϓσʔτ
    IUUQTHJUIVCDPN2VJDL2VJDLSFMFBTFT
    IUUQTHJUIVCDPNLS[ZT[UPG[BCMPDLJ4PVSDFSZSFMFBTFT

    View full-size slide

  26. mixi, Inc.
    ܾΊͨ͜ͱ r Ҡߦܭը
    ˔ 4XJGUʹඋ͑ͯɺݱঢ়ग़͍ͯΔΤϥʔ΍ϫʔχϯάʹରԠ͢Δ
    ˓ 9GSPOUFOEXBSODPODVSSFODZ
    ˓ 9GSPOUFOEFOBCMFBDUPSEBUBSBDFDIFDLT
    ˔ ৽نͰ࡞ΔػೳͰੵۃతʹ࠾༻͍ͯ͘͠
    ˔ طଘͷػೳʹґଘ͢Δඞཁ͕͋Δ৔߹͸ҎԼ͔Βબ୒
    ˓ طଘͷඇಉظॲཧΛ BTZODϝιουʹஔ͖׵͍͑ͯ͘
    ˓ ৽نͰ BTZODϝιουΛ࡞੒ͯ͠ঃʑʹஔ͖׵͍͑ͯ͘ Өڹൣғ͕޿ͯ͘ஔ׵͕େมͳͱ͖

    ˙ 3Y4XJGU4XJGU$PODVSSFODZରԠόʔδϣϯ·ͰΞοϓσʔτͯ͠ 0CTFSWBCMFˠBTZODม׵
    ˙ ΫϩʔδϟXJUI$IFDLFE 5ISPXJOH
    $POUJOVBUJPOΛ࢖ͬͯ BTZODʹม׵
    ˔ ϦϦʔεલʹ͸֤04όʔδϣϯͰͷ2"Λߦ͏
    IUUQTGPSVNTTXJGUPSHUDPODVSSFODZJOTXJGUBOEDPODVSSFODZJOTXJGUBOE

    View full-size slide

  27. mixi, Inc.
    ·ͱΊ
    ˔ ΈͯͶʹ4XJGU$PODVSSFODZΛಋೖ͢Δʹܾ͋ͨͬͯΊͨ͜ͱΛɺݕ౼աఔͰग़͖ͯͨબ୒ࢶͱͱ
    ΋ʹઆ໌
    ˓ ň͏ͪͰ͸͜͏ܾΊͨΑʼnňͬͪ͜ͷ΄͏͕͍͍Μ͡Όͳ͍ ʼnͱ͍͏πΠʔτͰ੝Γ্͕͍ͬͯͨΒخ͍͠
    ˔ ࣮ࡍʹಋೖͯ͠ΈͯಘΒΕͨ஌ݟʹ͍ͭͯ΋ॱ࣍ൃ৴͍͖͍ͯͨ͠

    View full-size slide