Slide 1

Slide 1 text

J04%$+BQBO5SBDL"d ࠲ஊձ 4USJDU$PODVSSFODZͱ4XJGU͕ ։͘৽࣌୅ࢲͨͪ͸Ͳ͏ੜ͖Δ͔ʁ ొஃऀLOUL LPIFS PNPDIJNFUBSV ·ͭ͡ TIJ[

Slide 2

Slide 2 text

ࣗݾ঺հ ࣗݾ঺հ

Slide 3

Slide 3 text

LOULʢΧωλΧʣ wגࣜձࣾϝϧΧϦ wϒʔεʹͯ4XJGUΫΠζ

Slide 4

Slide 4 text

!LPIFS Heart of Swift

Slide 5

Slide 5 text

w -*/&Ϡϑʔגࣜձࣾ -*/&J04 w 9!NUK@K ·ͭ͡

Slide 6

Slide 6 text

!PNPDIJNFUBSV

Slide 7

Slide 7 text

ࣗݾ঺հ !TU[O TIJ[ʢͣ͠ʣ w -*/&Ϡϑʔגࣜձࣾ

Slide 8

Slide 8 text

ຊ೔ͷ಺༰ w 4XJGU$PODVSSFODZͷཧղΛਂΊΔ w ೝࣝ߹Θͤ w *TPMBUJPO͕Θ͔Γ·ͤΜʂ w σʔλΛอޢ͢Δͱ͖͸͢΂ͯBDUPSΛ࢖͏΂͖Ͱ͔͢ʁ w $PNQMFUF4USJDU$PODVSSFODZ΁ͷҠߦઓུΛߟ͑Δ w J04ΞϓϦ։ൃʹదͨ͠$PODVSSFODZͷ࢖͍ํ͸͋Γ·͔͢ʁ w ͍ͭ·Ͱʹ4USJDU$PODVSSFODZରԠ͢Ε͹ྑ͍Ͱ͔͢ʁ w Ͳ͔͜ΒҠߦΛ࢝ΊΔͱྑ͍Ͱ͔͢ʁ w Ͳ͏΍ͬͯҠߦ͍ͯ͘͠ͱྑ͍Ͱ͔͢ʁ w 4XJGU$PODVSSFODZͷֶशํ๏ w 4XJGUͷؾʹͳΔഁյతมߋ w 4&'PSXBSE5SBJMJOH$MPTVSFT w ஫໨ͷ4XJGUͷ৽ػೳ w 4&4XJGU#BDLUSBDF"1*

Slide 9

Slide 9 text

4XJGU$PODVSSFODZͷ ཧղΛਂΊΔ

Slide 10

Slide 10 text

ࣄલΞϯέʔτ

Slide 11

Slide 11 text

͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ ࣄલΞϯέʔτͷ݁Ռ

Slide 12

Slide 12 text

ظؒ ۚ d ೔ ճ౴਺໊ Ξϯέʔτ݁Ռ ࣄલΞϯέʔτͷ݁Ռ

Slide 13

Slide 13 text

͍͍͑ ͸͍ 4XJGU$PODVSSFODZΛ࢖͍ͬͯ·͔͢ʁ ࣄલΞϯέʔτͷ݁Ռ

Slide 14

Slide 14 text

ྑ͍఺ wՄಡੑ্͕͕ͬͨ w ίʔυ͕࣮ߦ͞ΕΔॱ൪͕෼͔Γ΍͘͢ͳͬͨ ॲཧ͕௥͍΍͍͢ wॻ͖΍͘͢ͳͬͨ w ඇಉظॲཧΛಉظతʹॻ͚Δ ୤ίʔϧόοΫ஍ࠈɺϧʔϓॲཧ w ߏ଄Λҙࣝͯ͠ॻ͚Δ w ͔ͬ͜Αͯ͘ؾ෼͕͍͍ wίϯύΠϥ͕νΣοΫͯ͘͠ΕΔͷͰ҆৺ײ͕૿ͨ͠ w εϨουηʔϑΛอূͯ͘͠ΕΔ w σουϩοΫ͕ͳ͘ͳͬͨ ࣄલΞϯέʔτͷ݁Ռ ͸͍ͱ ౴͑ͨํ

Slide 15

Slide 15 text

ྑͦ͞͏ͩͱࢥ͏఺ wΑΓ҆શʹͳΓͦ͏ w ίϯύΠϥ͕νΣοΫͯ͘͠ΕΔ w εϨουΛؾʹͤͣʹ҆શʹϓϩάϥϛϯά͕Ͱ͖ͦ͏ w σʔλڝ߹΁ͷෆ͕҆ݮΔ wಡΈ΍͘͢ͳΓͦ͏ w ίʔϧόοΫΛ࢖ͬͨඇಉظॲཧ͕γϯϓϧʹͳͬͯݟ΍ͦ͢͏ wΑΓॻ͖΍͘͢ͳΓͦ͏ w EFMFHBUF΍Ϋϩʔδϟͱൺ΂ͯඇಉظॲཧ͕Χϯλϯʹॻ͚ͦ͏ w 4XJGU6*΍"QQMFͷϑϨʔϜϫʔΫͱͷ૬ੑ͕Αͦ͞͏ w ωετ͕ݮΓͦ͏ ࣄલΞϯέʔτͷ݁Ռ ͍͍͑ͱ ౴͑ͨํ

Slide 16

Slide 16 text

೉͍͠఺ wֶशίετ͕ߴ͍ w ֮͑Δ͜ͱ͕͍ͬͺ͍͋Δ w Ͳ͜ͰֶΜͰ͍͍ͷ͔Θ͔Βͳ͍ w ֓೦͕೉͍͠ "DUPS*TPMBUJPOɺฒߦϓϩάϥϛϯάࣗମʜͳͲ wܯࠂ΍Τϥʔ͕Θ͔Βͳ͍ w ཧ༝͕Α͘Θ͔Βͳ͍ w Ͳ͏ରॲ͢Ε͹͍͍͔Θ͔Βͳ͍ w ѻ͍ͮΒ͍ͱ͜Ζ͕͋Δ w BDUPSϦΤϯτϥϯτɺΩϟϯηϧॲཧɺBDUPSҎ֎ͷՄมঢ়ଶͷ؅ཧɺϓ ϩάϨεͷ؅ཧɺ5BTLͷ࣮ߦॱংʜͳͲ ࣄલΞϯέʔτͷ݁Ռ ͸͍ͱ ౴͑ͨํ

Slide 17

Slide 17 text

೉ͦ͠͏ͩͱࢥ͏఺ wֶशίετ͕͔͔Γͦ͏ w 5BTL΍ΞΫλʔͱ͍ͬͨ֓೦ͷΩϟονΞοϓ w ·ͣɺ4FOEBCMF͕Θ͔Γʹ͘͘ɺԿΛ4FOEBCMFʹ͢΂͖ͳͷ͔͕͸͖ͬΓ͠ͳ͍ w࢖͍ํ͕೉ͦ͠͏ w σόοάํ๏ w Τϥʔϝοηʔδͷղಡ w ಛఆͷόοΫάϥ΢ϯυΩϡʔΛ࢖͏ํ๏ w ۩ମతͳΠϝʔδ͕༙͍͍ͯͳ͍ wҠߦ͕େมͦ͏ ࣄલΞϯέʔτͷ݁Ռ ͍͍͑ͱ ౴͑ͨํ

Slide 18

Slide 18 text

ೝࣝ߹Θͤ

Slide 19

Slide 19 text

4XJGU$PODVSSFODZ͸ σʔλڝ߹Λ๷͍Ͱ͘ΕΔ

Slide 20

Slide 20 text

%BUBSBDF σʔλڝ߹ εϨου εϨου σʔλ ॻ͖ ಡΈ ಉ࣌ʹൃੜ 💥 ˞ಡΈࠐΈ͚ͩͷ৔߹͸σʔλڝ߹Ͱ͸ͳ͍ Կ͕ى͜Δ͔ Θ͔Βͳ͍

Slide 21

Slide 21 text

3BDFDPOEJUJPO ڝ߹ঢ়ଶ εϨουͷ࣮ߦॱংʹΑͬͯσʔλ͕มΘͬͯ͠·͏ εϨου εϨου σʔλ σʔλ εϨου εϨου σʔλ σʔλ ࣌ʑ ࣅ͍ͯΔ͚Ͳҧ͏

Slide 22

Slide 22 text

%BUBSBDF σʔλڝ߹ 3BDFDPOEJUJPO ڝ߹ঢ়ଶ

Slide 23

Slide 23 text

%BUB*TPMBUJPO σʔλִ཭ w 4XJGUίϯύΠϥ͕͢΂ͯͷNVUBCMFTUBUF Մมঢ়ଶ ΛνΣο Ϋ͠ɺෳ਺εϨου͔Βಉ࣌ΞΫηεͰ͖ͳ͍ͯ͘͠Δ࢓૊Έ w ੩త TUBUJD ִ཭ͱಈత EZOBNJD ִ཭ͷछྨ͋Δ w ੩తִ཭ܕ΍ؔ਺ͷએݴͳͲ࣮ߦ࣌ͷঢ়ଶʹࠨӈ͞Εͳ͍ཁૉͰ ִ཭͢Δ࢓૊Έ ྫBDUPSɺ!.BJO"DUPS w ಈతִ཭੩తʹִ཭Ͱ͖ͳ͍৔߹ʹִ཭ΛίϯύΠϥʹ఻͑Δ ࢓૊ΈɻҰ࣌తͳղܾࡦ ྫ.BJO"DUPSBTTVNF*TPMBUFEɺ.BJO"DUPSSVO

Slide 24

Slide 24 text

ඇִ཭ OPOJTPMBUFE ໌ࣔతͳִ཭υϝΠϯ ΞΫλʔάϩʔόϧΞΫλʔ ʹଐ͞ͳ͍ঢ়ଶ ྫ௨ৗͷؔ਺΍σʔλߏ଄ɺOPOJTPMBUFE͕෇͍͍ͯΔ΋ͷ ΞΫλʔִ཭ BDUPSJTPMBUFE ϝιου΍ม਺͕ΞΫλʔ͕࡞ΔυϝΠϯʹִ཭͞Ε͍ͯΔঢ়ଶ ྫBDUPSΫϥεɺJTPMBUFEύϥϝʔλΛ࣋ͭؔ਺ άϩʔόϧΞΫλʔִ཭ HMPCBMBDUPSJTPMBUFE ϝιου΍ม਺͕άϩʔόϧΞΫλʔ͕࡞ΔυϝΠϯʹִ཭͞Ε͍ͯΔঢ়ଶ ྫ!.BJO"DUPSɺಠࣗʹఆٛͨ͠άϩʔόϧΞΫλʔ *TPMBUJPO%PNBJO ִ཭υϝΠϯ σʔλִ཭ʹΑͬͯϝιου΍ม਺Λִ཭͍ͯ͠ΔݸʑͷྖҬ

Slide 25

Slide 25 text

actor Counter { var actorIsolated = 0 let constant = 100 var nonSendableClass = NonSendableClass() func increment() { actorIsolated += randomNumber() } func incrementWithGlobalActorIsolated() async { actorIsolated += await globalActorIsolated } @MainActor var globalActorIsolated = 0 @MainActor var globalActorIsolatedValue: Int { globalActorIsolated } nonisolated var nonisolatedValue: Int { get async { await actorIsolated } } nonisolated func randomNumber() -> Int { Int.random(in: 0..

Slide 26

Slide 26 text

actor Counter { var actorIsolated = 0 let constant = 100 var nonSendableClass = NonSendableClass() func increment() { actorIsolated += randomNumber() } func incrementWithGlobalActorIsolated() async { actorIsolated += await globalActorIsolated } @MainActor var globalActorIsolated = 0 @MainActor var globalActorIsolatedValue: Int { globalActorIsolated } nonisolated var nonisolatedValue: Int { get async { await actorIsolated } } nonisolated func randomNumber() -> Int { Int.random(in: 0..

Slide 27

Slide 27 text

ִ཭ڥքΛ௒͑Δ ஋ άϩʔόϧ ΞΫλʔִ཭ ΞΫλʔִ཭ ஋

Slide 28

Slide 28 text

w σʔλִ཭ %BUB*TPMBUJPO w ੩త TUBUJD ִ཭ͱಈత EZOBNJD ִ཭ͷछྨ͋Δ w ִ཭υϝΠϯ w σʔλִ཭ʹΑͬͯϝιου΍ม਺Λִ཭͍ͯ͠ΔݸʑͷྖҬ w ͢΂ͯͷม਺ͱؔ਺͸ɺඇִ཭ɺΞΫλʔִ཭ɺάϩʔόϧΞΫλʔִ ཭ͷ͍ͣΕ͔ʹؚ·ΕΔ w ִ཭ڥք w ִ཭υϝΠϯؒͷڥք w ִ཭ڥքΛӽ͑Δ w ҟͳΔछྨͷִ཭υϝΠϯؒͰ஋͕౉͞ΕΔ͜ͱ άϩʔ όϧΞΫ λʔִ཭ ΞΫλʔ ִ཭ ඇִ཭ ִ཭υϝΠϯ ִ཭ڥք ִ཭ڥքΛӽ͑Δ

Slide 29

Slide 29 text

*TPMBUJPO͕Θ͔Γ·ͤΜʂ

Slide 30

Slide 30 text

ִ཭υϝΠϯΛ௒͑ΒΕΔ৚݅ w 4FOEBCMFʹ४ڌ͍ͯ͠Δ w खಈͰίϯύΠϥͷνΣοΫΛআ֎͍ͯ͠ΔϦεΫΛແࢹ͢ΔͨΊཁ஫ҙ ྫ!VODIFDLFE4FOEBCMFɺ!QSFDPODVSFODZ w 4XJGU /PO4FOEBCMFͰ΋ϑϩʔηϯγςΟϒִ཭ղੳ 3FHJPO CBTFEJTPMBUJPO Ͱ҆શͩͱݟͳ͞Εͨ w 4XJGU TFOEJOHΩʔϫʔυͷ෇͍ͨ/PO4FOEBCMFͳύϥϝʔ λɺ໭Γ஋

Slide 31

Slide 31 text

JTPMBUJPOͷॻ͖෼͚ ؔ਺ Ϋϩʔδϟ OPOJTPMBUFE UZQF JTPMBUFE QBSBNFUFS JTPMBUFE DBQUVSFE WBMVF JTPMBUFE func nonisolatedFunction() async {} nonisolated func explicitNonisolatedFunction() async {} func nonisolatedContext() async { let implicitNonisolatedClosure = { () in } // [SE-NNNN] Closure isolation control let nonisolatedClosure = { nonisolated () in } } @MainActor func typeIsolatedFunction() async {} @MainActor func typeContext() async { let implicitTypeIsolatedClosure = { () in } let typeIsolatedClosure = { @MainActor in } } func parameterIsolatedFunction( myActor: isolated MyActor ) async {} extension MyActor { func selfIsolatedFunction() async {} } let parameterIsolatedClosure = { (myActor: isolated MyActor) in } extension MyActor { var selfCapturedIsolatedFunction: () async -> Void { self.selfIsolatedFunction } } // [SE-NNNN] Closure isolation control let myActor = MyActor() let captureIsolatedClosure = { [isolated myActor] () in }

Slide 32

Slide 32 text

ࠓޙσʔλΛอޢ͢Δͱ͖͸ ͢΂ͯBDUPSΛ࢖͏΂͖Ͱ͔͢ʁ

Slide 33

Slide 33 text

جຊ͸"DUPS w 4XJGU$PODVSSFODZ͸εϨουΛϒϩοΫ͠ͳ͍ࢥ૝ w ੑೳ௿Լʹܨ͕Δ w "DUPS΋εϨουΛϒϩοΫ͠ͳ͍ w "DUPS͸σουϩοΫΛى͜͞ͳ͍ w SBDFDPOEJUJPOͷ໰୊͕ى͖ಘΔ w ΫϦςΟΧϧηΫγϣϯʹBXBJU͕ೖͬͯ͸͍͚ͳ͍

Slide 34

Slide 34 text

جຊ͸"DUPS͕ͩʜ w 4XJGUνʔϜ΋શͯ"DUPSʹஔ͖׵͑ΒΕΔͱ͸ߟ͍͑ͯͳ͍ w ΫϦςΟΧϧηΫγϣϯ w BTZODΛ࢖͑ͳ͍৔߹ʢϨΨγʔίʔυɾͲ͏ͯ͠΋ಉظΞΫηε͍ͨ͠ʣ w ˠ.VUFY "UPNJD

Slide 35

Slide 35 text

.VUFY w εϨουΛಉظϒϩοΫ͢Δʮ-PDLʯͷϥούʔ w PT@VOGBJS@MPDLʢ04"MMPDBUFE6OGBJS-PDLʣΛ಺෦Ͱར༻ class FancyManagerOfSorts { let cache = Mutex<[String: Resource]>([:]) func save(_ resource: Resource, as key: String) { cache.withLock { $0[key] = resource } } }

Slide 36

Slide 36 text

"UPNJD w εϨουΛʢҰॠ͚ͩʣಉظϒϩοΫ͢Δ"1* w EBUBSBDF͚ͩΛಉظతʹ๷͍͗ͨ৔߹ let counter = Atomic(0) DispatchQueue.concurrentPerform(iterations: 10) { _ in for _ in 0 ..< 1_000_000 { counter.wrappingAdd(1, ordering: .relaxed) } } print(counter.load(ordering: .relaxed))

Slide 37

Slide 37 text

.VUFYɾ"UPNJD w ͨͩ͠4XJGU J04Ҏ্ʜ w .VUFYͷ୅ସʹ04"MMPDBUFE6OGBJS-PDLΛ࢖͑͹0,

Slide 38

Slide 38 text

wجຊ͸"DUPS w 4XJGU$PODVSSFODZ͸εϨουΛϒϩοΫ͠ͳ͍ࢥ૝ w "DUPS͸σουϩοΫΛى͜͞ͳ͍ ͨͩ͠ɺSBDFDPOEJUJPOΛى͜͢ w4XJGUνʔϜ΋શͯ"DUPSʹஔ͖׵͑ΒΕΔͱ͸ߟ͍͑ͯͳ͍ w ΫϦςΟΧϧηΫγϣϯ w BTZODΛ࢖͑ͳ͍৔߹ʢϨΨγʔίʔυɾͲ͏ͯ͠΋ಉظΞΫηε͍ͨ͠ʣ w.VUFYɺ"UPNJD ͨͩ͠ɺ4XJGUJ04Ҏ্ w J04Ҏલ͸ 04"MMPDBUFE6OGBJS-PDL͕.VUFYͷ୅ΘΓʹ࢖͑Δ

Slide 39

Slide 39 text

$PNQMFUF4USJDU$PODVSSFODZ ΁ͷҠߦઓུΛߟ͑Δ

Slide 40

Slide 40 text

͍͍͑ ͸͍ $PNQMFUF4USJDU$PODVSSFODZνΣοΫΛ࢖͍ͬͯ·͔͢ʁ ࣄલΞϯέʔτͷ݁Ռ

Slide 41

Slide 41 text

ྑ͍఺ wରԠՕॴ͕໌֬ʹͳͬͨ w҆શੑ͕ߴ·ͬͨ w ΑΓ׬ᘳͳεϨουηʔϑঢ়ଶΛ࡞ΕΔ wஈ֊తʹҠߦͰ͖Δ w Ϟδϡʔϧ͝ͱʹҠߦ͠΍͍͢ w ໰୊Λૣظʹൃݟ͠΍͍͢ w ܯࠂ͕෼͔Γ΍͍͢ ͸͍ͱ ౴͑ͨํ ࣄલΞϯέʔτͷ݁Ռ

Slide 42

Slide 42 text

ྑͦ͞͏ͩͱࢥ͏఺ wରԠՕॴ͕ಛఆ͠΍͘͢ͳΓͦ͏ wΑΓ҆શʹͳΓͦ͏ w ίϯύΠϥνΣοΫ w ಉ࣌ΞΫηεʹΑΔϥϯλΠϜΫϥογϡ͕ݮΔ w σʔλڝ߹΁ͷෆ҆ wΑΓॻ͖΍͘͢ͳΓͦ͏ w ͜Ε·Ͱ2VFVF΍-PDLͳͲΛ࢖͍ͬͯͨ෦෼͕؆୯ʹॻ͚ͯྑͦ͞͏ ͍͍͑ͱ ౴͑ͨํ ࣄલΞϯέʔτͷ݁Ռ

Slide 43

Slide 43 text

೉͍͠఺ wܯࠂʹ͍ͭͯ w ࢦఠ͕ଟ͗ͯ͢Ͳ͏मਖ਼͢΂్͖͔ํʹ͘ΕΔ w ࣮ࡍʹ͸ฒߦΞΫηε͕ى͖ͳ͍৔໘Ͱ΋ίϯύΠϥΛ໧ΒͤΔͨΊʹ৭ʑ΍Δ࡞ۀ͕ੜ ·Εͨ w ຊ౰ʹܯࠂ͍ͯ͠Δͷ͔ίϯύΠϥͷόά͔͕෼͔Βͳ͍ wະରԠͷϥΠϒϥϦ΍ϑϨʔϜϫʔΫͷར༻ w ϫʔΫΞϥ΢ϯυ͕ඞཁʹͳͬͯ໘౗ wҠߦίετ͕͔͔Γͦ͏ ͸͍ͱ ౴͑ͨํ ࣄલΞϯέʔτͷ݁Ռ

Slide 44

Slide 44 text

೉ͦ͠͏ͩͱࢥ͏఺ wܯࠂ΍Τϥʔ͕೉ͦ͠͏ w ϝοηʔδͷղಡ͕೉ͦ͠͏ w ܯࠂ΍Τϥʔमਖ਼ʹࠎ͕ંΕͦ͏ɻ%POUQBOJD͸ແཧ w طଘͷ໰୊͕ͳ͍ίʔυʹରͯ͠ܯࠂ΍Τϥʔ͕ग़ͯ͠·͏ જࡏతʹ͸໰୊͸͋Δ w ͦ΋ͦ΋ɺͳʹΛνΣοΫͯ͠Δͷ͔͑͞ཧղग़དྷ͍ͯͳ͍ wطଘͷίʔυ͔ΒͷҠߦϓϩηε͕Θ͔Βͳ͍ w ࣗ෼ͷϓϩδΣΫτʹ߹ͬͨҠߦํ๏͕Θ͔Βͳ͍ w શମΛ$PODVSSFODZରԠͤ͞Δ͔ɺ!QSFDPODVSSFODZ౳ͷ࢑ఆରԠͤ͞Δͷ͔ w DMBTTͷѻ͍ํ w ࣮ϓϩμΫτͰͷஈ֊తͳਐΊํɻಛʹϑϨʔϜϫʔΫͷҠߦ͕ඞཁͳ৔߹ $PNCJOF͔Βͷ ஔ׵ͳͲ wҠߦίετ͕͔͔Γͦ͏ w طଘίʔυ͕ଟ͗ͯ͢Ҡߦ͸ແཧͦ͏ɻԼखͨ͠ΒϞσϧ͔Βม͑ͳ͍ͱ͍͚ͳ͍ w ޻਺ʹݟ߹ͬͨରԠ͢ΔϝϦοτ͸͋Δͷ͔ʁ ͍͍͑ͱ ౴͑ͨํ ࣄલΞϯέʔτͷ݁Ռ

Slide 45

Slide 45 text

J04ΞϓϦ։ൃʹదͨ͠ $PODVSSFODZͷ࢖͍ํ͸͋Γ·͔͢ʁ

Slide 46

Slide 46 text

ִ཭ڥքΛӽ͑ͳ͚Ε͹೉͍͜͠ͱ͸ͳ͍ .BJO"DUPS ִ཭ڥք *TPMBUJPO#PVOEBSZ 7JFX 7JFX 7JFX .PEFM 7JFX .PEFM .PEFM .PEFM .PEFM .BJO"DUPS಺Ͱͷ΍ΓͱΓʹ೉͠͞͸ͳ͍ (6*ΞϓϦͷଟ͘ͷ࣮૷͸ .BJO"DUPS಺ʹͱͲ·Δ

Slide 47

Slide 47 text

7JFX͔Β௚઀ΞΫηε͢Δঢ়ଶ͸.BJO"DUPSͰѻ͏ struct FooListView: View { @State var viewModel: FooViewModel = .init() var body: some View { List(viewModel.values) { value in // ... } } }

Slide 48

Slide 48 text

ྫ.BJO"DUPSͰ΍Ε͹ྑ͍ॲཧ @MainActor @Observable final class FooStore { var idToValue: [Foo.ID: Foo] = [:] } @MainActor @Observable final class FooListViewModel { let store: FooStore var values: [Foo] { // O(n)͚ͩͲཁૉ਺͕ଟ͘ͳ͍ݶΓ໰୊ͳ͍ Array(store.idToValue.values) } }

Slide 49

Slide 49 text

ྫෆཁʹִ཭ڥքΛӽ͑Δͱ೉͘͠ͳΔ actor FooStore { var idToValue: [Foo.ID: Foo] = [:] var values: [Foo] { Array(idToValue.values) } } @MainActor @Observable final class FooListViewModel { let store: FooStore var isBar: Bool = false func load() async { if isBar { return } let values = await Array(store.idToValue.values) if isBar { return } // suspension pointΛڬΜͩͷͰ࠶νΣοΫ // ... } }

Slide 50

Slide 50 text

͍ͭ·Ͱʹ4USJDU$PODVSSFODZ ରԠ͢Ε͹ྑ͍Ͱ͔͢ʁ

Slide 51

Slide 51 text

9DPEF·ͰʹରԠ͠ͳͯ͘΋ྑ͍ w $PNQMFUF4USJDU$PODVSSFODZνΣοΫͰܯࠂ͕ग़Δίʔυ͸4XJGUͰ͸ ίϯύΠϧΤϥʔͱͳΔ w 9DPEFͰ΋4XJGUݴޠϞʔυͰར༻Ͱ͖Δ w 4XJGUݴޠϞʔυͰ$PNQMFUF4USJDU$PODVSSFODZνΣοΫΛ༗ޮʹ͠ɺ ܯࠂʹରԠ͢Δ w ܯࠂ͕ͳ͘ͳͬͨΒ4XJGUݴޠϞʔυʹมߋ͢Δ

Slide 52

Slide 52 text

Ͳ͔͜ΒҠߦΛ࢝ΊΔͱ ྑ͍Ͱ͔͢ʁ

Slide 53

Slide 53 text

֎ଆ͔Β࢝ΊΔ w ֎ଆ࠷্ҐϞδϡʔϧ ϝΠϯλʔήοτͳͲ w ཧ༝ଞͷϞδϡʔϧ͔Βґଘ͞Ε͍ͯͳ͍ͨΊӨڹൣғΛ཈͑ΒΕΔ w ஫ҙઈରʹ͔͜͜Βͱ͍͏Θ͚Ͱ͸ͳ͍ w σʔλڝ߹҆શͰͳ͍άϩʔόϧͳঢ়ଶ΍ࣗಈͰ4FOEBCMFʹ४ڌ͍ͯ͠Δ ܕͷ͍ͤͰϓϩδΣΫτதʹܯࠂ͕େྔൃੜ͍ͯ͠Δ৔߹͸ɺͦͪΒΛ·ͣ ର৅ͱ͢Δͷ͕࠷΋ޮՌత ӳޠ൛ ೔ຊޠ൛

Slide 54

Slide 54 text

Ͳ͏΍ͬͯҠߦ͍ͯ͘͠ͱ ྑ͍Ͱ͔͢ʁ

Slide 55

Slide 55 text

%BUBSBDFͷݪҼ͔Β Ҡߦ͢Δํ๏Λߟ͑Δ

Slide 56

Slide 56 text

%BUBSBDFͷओཁͳݪҼ w ϛϡʔλϒϧͳΫϥε w άϩʔόϧม਺

Slide 57

Slide 57 text

%BUBSBDFͷओཁͳݪҼ w ϛϡʔλϒϧͳΫϥε w άϩʔόϧม਺ class Counter { var value = 0 func increment() -> Int { ... } }

Slide 58

Slide 58 text

%BUBSBDFͷओཁͳݪҼ w ϛϡʔλϒϧͳΫϥε w άϩʔόϧม਺ TUSVDUʹͰ͖ͳ͍͔ߟ͑Δ BDUPSʹͰ͖ͳ͍͔ߟ͑Δ 04"MMPDBUFE6OGBJS-PDLΛ࢖ͬͯ4FOEBCMFʹ͢Δ SFHJPOCBTFEJTPMBUJPOͰ৐Γ੾Δ class Counter { var value = 0 func increment() -> Int { ... } }

Slide 59

Slide 59 text

%BUBSBDFͷओཁͳݪҼ w ϛϡʔλϒϧͳΫϥε w άϩʔόϧม਺ class FooManager { static var configuration = Configuration() }

Slide 60

Slide 60 text

%BUBSBDFͷओཁͳݪҼ w ϛϡʔλϒϧͳΫϥε w άϩʔόϧม਺ 4FOEBCMFͷ৔߹ OPO4FOEBCMFͷ৔߹ class FooManager { static var configuration = Configuration() }

Slide 61

Slide 61 text

%BUBSBDFͷओཁͳݪҼ w ϛϡʔλϒϧͳΫϥε w άϩʔόϧม਺ 4FOEBCMFͷ৔߹ TUBUJDMFUDPNQVUFEQSPQFSUZʹ͢Δ BDUPSʹִ཭͢Δ OPOJTPMBUFE VOTBGF MPDLΛ࢖͏ OPO4FOEBCMFͷ৔߹ class FooManager { static var configuration = Configuration() }

Slide 62

Slide 62 text

%BUBSBDFͷओཁͳݪҼ w ϛϡʔλϒϧͳΫϥε w άϩʔόϧม਺ 4FOEBCMFͷ৔߹ TUBUJDMFUDPNQVUFEQSPQFSUZʹ͢Δ BDUPSʹִ཭͢Δ OPOJTPMBUFE VOTBGF MPDLΛ࢖͏ ؤுͬͯ4FOEBCMFʹ͢Δ DPNQVUFEQSPQFSUZʹ͢Δ BDUPSʹִ཭͢Δ OPOJTPMBUFE VOTBGF Λ࢖͏ OPO4FOEBCMFͷ৔߹ class FooManager { static var configuration = Configuration() }

Slide 63

Slide 63 text

%BUBSBDFͷओཁͳݪҼ w ϛϡʔλϒϧͳΫϥε w άϩʔόϧม਺ TUSVDUʹͰ͖ͳ͍͔ߟ͑Δ BDUPSʹͰ͖ͳ͍͔ߟ͑Δ 04"MMPDBUFE6OGBJS-PDLΛ࢖ͬͯ4FOEBCMFʹ͢Δ SFHJPOCBTFEJTPMBUJPOͰ৐Γ੾Δ 4FOEBCMFͷ৔߹ TUBUJDMFUDPNQVUFEQSPQFSUZʹ͢Δ BDUPSʹִ཭͢Δ OPOJTPMBUFE VOTBGF MPDLΛ࢖͏ ؤுͬͯ4FOEBCMFʹ͢Δ DPNQVUFEQSPQFSUZʹ͢Δ BDUPSʹִ཭͢Δ OPOJTPMBUFE VOTBGF Λ࢖͏ OPO4FOEBCMFͷ৔߹

Slide 64

Slide 64 text

ؤுͬͯ4FOEBCMFʹ͢Δ DPNQVUFEQSPQFSUZʹ͢Δ BDUPSʹִ཭͢Δ OPOJTPMBUFE VOTBGF Λ࢖͏ TUBUJDMFUDPNQVUFEQSPQFSUZʹ͢Δ BDUPSʹִ཭͢Δ OPOJTPMBUFE VOTBGF MPDLΛ࢖͏ TUSVDUʹͰ͖ͳ͍͔ߟ͑Δ BDUPSʹͰ͖ͳ͍͔ߟ͑Δ 04"MMPDBUFE6OGBJS-PDLΛ࢖ͬͯ4FOEBCMFʹ͢Δ SFHJPOCBTFEJTPMBUJPOͰ৐Γ੾Δ %BUBSBDFͷओཁͳݪҼ w ϛϡʔλϒϧͳΫϥε w άϩʔόϧม਺ 4FOEBCMFͷ৔߹ OPO4FOEBCMFͷ৔߹ BDUPSʹִ཭͢Δ BDUPSʹִ཭͢Δ BDUPSʹͰ͖ͳ͍͔ߟ͑Δ

Slide 65

Slide 65 text

BDUPSΛಋೖ͢Δ͜ͱͰࠓ·Ͱʹͳ͍Τϥʔ͕ൃੜ BTZODΛ෇͚଍͢ඞཁ͕͋Δ౳

Slide 66

Slide 66 text

BDUPSʹ·ͭΘΔΑ͋͘ΔΤϥʔ ར༻Օॴ͕ଟִ͗ͯ͢཭Ͱ͖ͳ͍ !QSFDPODVSSFODZBDUPS QSPUPDPM͕ཁٻ͢ΔBDUPSͱ ͋Δ΂͖BDUPS͕ҧ͏ QSFDPODVSSFODZDPOGPSNBODF OPOJTPMBUFEBTTVNF*TPMBUFE OPOJTPMBUFE5BTL EFJOJU͕BDUPSʹִ཭͞Εͳ͍ EFJOJUͰඞཁͳ΋ͷʹ OPOJTPMBUFE VOTBGF Λ෇͚଍͢ EFJOJUͰඞཁͳ΋ͷΛBDUPSʹ ִ཭ͨ͠ϥούʔΛڬΉ

Slide 67

Slide 67 text

ΑΓৄ͘͠͸ IUUQT[FOOEFWNBUTVKJBSUJDMFTGEGFB

Slide 68

Slide 68 text

%BUBSBDFͷओཁͳݪҼ BDUPSʹ·ͭΘΔΑ͋͘ΔΤϥʔ ར༻Օॴ͕ଟ͗ͯ͢ ִ཭Ͱ͖ͳ͍ !QSFDPODVSSFODZBDUPS QSPUPDPM͕ ཁٻ͢ΔBDUPSͱ ͋Δ΂͖BDUPS ͕ҧ͏ QSFDPODVSSFODZDPOGPSNBODF OPOJTPMBUFEBTTVNF*TPMBUFE OPOJTPMBUFE5BTL EFJOJU͕ BDUPSʹ ִ཭͞Εͳ͍ EFJOJUͰඞཁͳ΋ͷʹ OPOJTPMBUFE VOTBGF Λ෇͚଍͢ EFJOJUͰඞཁͳ΋ͷΛBDUPSʹ ִ཭ͨ͠ϥούʔΛڬΉ w ϛϡʔλϒϧͳΫϥε w άϩʔόϧม਺ TUSVDUʹͰ͖ͳ͍͔ߟ͑Δ BDUPSʹͰ͖ͳ͍͔ߟ͑Δ 04"MMPDBUFE6OGBJS-PDL4FOEBCMF SFHJPOCBTFEJTPMBUJPOͰ৐Γ੾Δ 4FOEBCMFͷ৔߹ TUBUJDMFUDPNQVUFEQSPQFSUZ BDUPSʹִ཭͢Δ OPOJTPMBUFE VOTBGF MPDL ؤுͬͯ4FOEBCMFʹ͢Δ DPNQVUFEQSPQFSUZʹ͢Δ BDUPSʹִ཭͢Δ OPOJTPMBUFE VOTBGF Λ࢖͏ OPO4FOEBCMFͷ৔߹

Slide 69

Slide 69 text

4XJGU$PODVSSFODZͷ ֶशํ๏

Slide 70

Slide 70 text

wجຊΛֶͿ w4XJGU.JHSBUJPO(VJEF IUUQTTXJGUNJHSBUJPOHVJEFKQEPDVNFOUBUJPONJHSBUJPOHVJEF wΑΓਂֶ͘Ϳ w88%$ͷಈըΛݟΔɻαϯϓϧίʔυΛࢼ͢ IUUQTEFWFMPQFSBQQMFDPNKQWJEFPTTXJGU wެࣜυΩϡϝϯτΛಡΉ IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOTXJGUDPODVSSFODZ

Slide 71

Slide 71 text

TXJGUMBOHTXJGUϦϙδτϦͷςετΛݟΔ w Ͳ͏͍͏Τϥʔ ܯࠂ ͕ग़ྗ͞ΕΔͷ͔͕ॻ͔Ε͍ͯΔ w ςετέʔε͕ͱͯ΋γϯϓϧͳͷͰΘ͔Γ΍͍͢ ϦϙδτϦ

Slide 72

Slide 72 text

ৄ͘͠͸͜͜ΛΫϦοΫ ྫҟͳΔHMPCBMBDUPSϝιουͷݺͼग़͠ @SomeGlobalActor protocol P1 { func method() } class C1: P1 { func method() { } @OtherGlobalActor func testMethod() { method() _ = method } } // expected-error {{call to global actor 'SomeGlobalActor'-isolated instance method 'method()' in a synchronous global actor 'OtherGlobalActor'-isolated context}}

Slide 73

Slide 73 text

ྫҟͳΔHMPCBMBDUPSϝιουͷݺͼग़͠ @SomeGlobalActor protocol P1 { func method() } class C1: P1 { func method() { } @OtherGlobalActor func testMethod() { method() _ = method } } // expected-error {{call to global actor 'SomeGlobalActor'-isolated instance method 'method()' in a synchronous global actor 'OtherGlobalActor'-isolated context}} Swift ConcurrencyͷཧղΛਂΊΔ > Τϥʔ(ܯࠂ)ͷௐ΂ํ ৄ͘͠͸͜͜ΛΫϦοΫ ࣮ࡍʹग़ྗ͞ΕΔจݴͱಉ͡

Slide 74

Slide 74 text

w4XJGU$PODVSSFODZΛཧղ͢Δ w 4XJGU.JHSBUJPO(VJEFΛಡΉ w 88%$ͷηογϣϯಈը w αϯϓϧίʔυΛࢼ͢ w ެࣜυΩϡϝϯτΛಡΉ w Τϥʔ΍ܯࠂͷௐ΂ํ w TXJGUMBOHTXJGUϦϙδτϦͷςετͰಉ͡ϝοηʔδ͕ग़ ྗ͞Ε͍ͯΔςετέʔεΛ୳ͯ͠ΈΔ

Slide 75

Slide 75 text

4XJGUͷؾʹͳΔഁյత มߋ

Slide 76

Slide 76 text

4&'PSXBSE5SBJMJOH$MPTVSFT 4&*NQMJDJU0QFO&YJTUFOUJBMT 4&/POGSP[FO&OVN&YIBVTUJWJUZ 4&#BSF4MBTI3FHFY-JUFSBMT 4&*NQPSU0CKD'PSXBSE%FDMBSBUJPOT 4&$PODJTF.BHJD'JMF 4&%FQSFDBUF"QQMJDBUJPO.BJO 4XJGUͷؾʹͳΔഁյతมߋ ࣄલΞϯέʔτͷ݁Ռ

Slide 77

Slide 77 text

4&'PSXBSE5SBJMJOH$MPTVSFT func f( _ onAppear: (() -> Void)? = nil, _ onDisappear: (() -> Void)? = nil ) { if onAppear != nil { print("forward") } if onDisappear != nil { print("backward") } } // Swift6ະຬ͸backward // Swift6Ҏ্͸forward f {}

Slide 78

Slide 78 text

஫໨ͷ4XJGUͷ৽ػೳ

Slide 79

Slide 79 text

4& 4& 4& 4& 4& 4& 4& 4& 4& 4& 4& 4& 4& 4& 4& 4& 4& 4& 4& 4& 4&5ZQFEUISPXT 4&4XJGU#BDLUSBDF"1* 4&0CKFDUJWF$JNQMFNFOUBUJPOTJO4XJGU 4&5BTL&YFDVUPS1SFGFSFODF 4&.FUBUZQF,FZQBUIT 4&"DDFTTMFWFMNPEJ fi FSTPOJNQPSUEFDMBSBUJPOT 4&$PVOUBCMF3BOHFQSPUPDPM 4&4XJGU-BOHVBHF7FSTJPO1FS5BSHFU 4&/PODPQZBCMF(FOFSJDT 4&1BDL*UFSBUJPO 4&/PODPQZBCMF4UBOEBSE-JCSBSZ1SJNJUJWFT 4&'PSFJHOSFGFSFODFUZQFTJO4XJGU 4&#PSSPXJOHBOEDPOTVNJOHQBUUFSONBUDIJOHGPS/PODPQZBCMFUZQFT 4&1PJOUFS"SHVNFOU&YQSFTTJPOT 4&CJU*OUFHFS5ZQFT 4&$SFBUFBSSBZPGCZUFTGSPNTUBUJDTUSJOHMJUFSBMT 4&"TZODEBUBTUSFBNT 4&"EEJOHPQBRVFQBSBNFUFSEFDMBSBUJPOT 4&"EE6OJDPEF4VQQPSUGPS3FHFYMJUFSBMT 4&'VODUJPO#PEZ.BDSPT 4XJGUҎ߱ͷؾʹͳΔ৽ػೳ ࣄલΞϯέʔτͷ݁Ռ ޙճ͠Ͱ΋Αͦ͞͏ʁ

Slide 80

Slide 80 text

4&5ZQFEUISPXT 2024/08/24 10:30ʙ Track A(͜͜) ొஃͷৄࡉ ϓϩϙʔβϧ

Slide 81

Slide 81 text

4&4XJGU#BDLUSBDF"1* ϓϩϙʔβϧ w όοΫτϨʔεΛऔಘ͢Δ"1*Λඪ४ϥΠϒϥϦʹ௥Ճ w γϯϘϧԽ΋Ͱ͖Δ w ൚༻తͳΫϥογϡϨϙʔλʔͱͯ͠࢖͑Δ΋ͷͰ͸ͳ͍ w ओͳ࢖༻༻్͸ɺ࣮ߦதʹόοΫτϨʔεΛϓϩάϥϜͰΩϟϓν ϟ͢Δ͜ͱ

Slide 82

Slide 82 text

·ͱΊ

Slide 83

Slide 83 text

4PGUXBSF%FTJHO݄߸ ܝࡌ༧ఆ 📣ࠂ஌📣

Slide 84

Slide 84 text

͋Γ͕ͱ͏͍͟͝·ͨ͠ ϑΟʔυόοΫ͓଴͍ͪͯ͠·͢