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

座談会 「Strict ConcurrencyとSwift 6が開く新時代: 私たちはどう生き...

座談会 「Strict ConcurrencyとSwift 6が開く新時代: 私たちはどう生きるか?」

iOSDC Japan 座談会スライド

[email protected]

August 23, 2024
Tweet

Other Decks in Programming

Transcript

  1. ຊ೔ͷ಺༰ 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*
  2. ྑ͍఺ wՄಡੑ্͕͕ͬͨ w ίʔυ͕࣮ߦ͞ΕΔॱ൪͕෼͔Γ΍͘͢ͳͬͨ ॲཧ͕௥͍΍͍͢ wॻ͖΍͘͢ͳͬͨ w ඇಉظॲཧΛಉظతʹॻ͚Δ ୤ίʔϧόοΫ஍ࠈɺϧʔϓॲཧ 

    w ߏ଄Λҙࣝͯ͠ॻ͚Δ w ͔ͬ͜Αͯ͘ؾ෼͕͍͍ wίϯύΠϥ͕νΣοΫͯ͘͠ΕΔͷͰ҆৺ײ͕૿ͨ͠ w εϨουηʔϑΛอূͯ͘͠ΕΔ w σουϩοΫ͕ͳ͘ͳͬͨ ࣄલΞϯέʔτͷ݁Ռ ͸͍ͱ ౴͑ͨํ
  3. ྑͦ͞͏ͩͱࢥ͏఺ wΑΓ҆શʹͳΓͦ͏ w ίϯύΠϥ͕νΣοΫͯ͘͠ΕΔ w εϨουΛؾʹͤͣʹ҆શʹϓϩάϥϛϯά͕Ͱ͖ͦ͏ w σʔλڝ߹΁ͷෆ͕҆ݮΔ wಡΈ΍͘͢ͳΓͦ͏ w

    ίʔϧόοΫΛ࢖ͬͨඇಉظॲཧ͕γϯϓϧʹͳͬͯݟ΍ͦ͢͏ wΑΓॻ͖΍͘͢ͳΓͦ͏ w EFMFHBUF΍Ϋϩʔδϟͱൺ΂ͯඇಉظॲཧ͕Χϯλϯʹॻ͚ͦ͏ w 4XJGU6*΍"QQMFͷϑϨʔϜϫʔΫͱͷ૬ੑ͕Αͦ͞͏ w ωετ͕ݮΓͦ͏ ࣄલΞϯέʔτͷ݁Ռ ͍͍͑ͱ ౴͑ͨํ
  4. ೉͍͠఺ wֶशίετ͕ߴ͍ w ֮͑Δ͜ͱ͕͍ͬͺ͍͋Δ w Ͳ͜ͰֶΜͰ͍͍ͷ͔Θ͔Βͳ͍ w ֓೦͕೉͍͠ "DUPS*TPMBUJPOɺฒߦϓϩάϥϛϯάࣗମʜͳͲ 

    wܯࠂ΍Τϥʔ͕Θ͔Βͳ͍ w ཧ༝͕Α͘Θ͔Βͳ͍ w Ͳ͏ରॲ͢Ε͹͍͍͔Θ͔Βͳ͍ w ѻ͍ͮΒ͍ͱ͜Ζ͕͋Δ w BDUPSϦΤϯτϥϯτɺΩϟϯηϧॲཧɺBDUPSҎ֎ͷՄมঢ়ଶͷ؅ཧɺϓ ϩάϨεͷ؅ཧɺ5BTLͷ࣮ߦॱংʜͳͲ ࣄલΞϯέʔτͷ݁Ռ ͸͍ͱ ౴͑ͨํ
  5. ೉ͦ͠͏ͩͱࢥ͏఺ wֶशίετ͕͔͔Γͦ͏ w 5BTL΍ΞΫλʔͱ͍ͬͨ֓೦ͷΩϟονΞοϓ w ·ͣɺ4FOEBCMF͕Θ͔Γʹ͘͘ɺԿΛ4FOEBCMFʹ͢΂͖ͳͷ͔͕͸͖ͬΓ͠ͳ͍ w࢖͍ํ͕೉ͦ͠͏ w σόοάํ๏ w

    Τϥʔϝοηʔδͷղಡ w ಛఆͷόοΫάϥ΢ϯυΩϡʔΛ࢖͏ํ๏ w ۩ମతͳΠϝʔδ͕༙͍͍ͯͳ͍ wҠߦ͕େมͦ͏ ࣄલΞϯέʔτͷ݁Ռ ͍͍͑ͱ ౴͑ͨํ
  6. %BUB*TPMBUJPO σʔλִ཭ w 4XJGUίϯύΠϥ͕͢΂ͯͷNVUBCMFTUBUF Մมঢ়ଶ ΛνΣο Ϋ͠ɺෳ਺εϨου͔Βಉ࣌ΞΫηεͰ͖ͳ͍ͯ͘͠Δ࢓૊Έ w ੩త TUBUJD

    ִ཭ͱಈత EZOBNJD ִ཭ͷछྨ͋Δ w ੩తִ཭ܕ΍ؔ਺ͷએݴͳͲ࣮ߦ࣌ͷঢ়ଶʹࠨӈ͞Εͳ͍ཁૉͰ ִ཭͢Δ࢓૊Έ ྫBDUPSɺ!.BJO"DUPS w ಈతִ཭੩తʹִ཭Ͱ͖ͳ͍৔߹ʹִ཭ΛίϯύΠϥʹ఻͑Δ ࢓૊ΈɻҰ࣌తͳղܾࡦ ྫ.BJO"DUPSBTTVNF*TPMBUFEɺ.BJO"DUPSSVO
  7. ඇִ཭ OPOJTPMBUFE  ໌ࣔతͳִ཭υϝΠϯ ΞΫλʔάϩʔόϧΞΫλʔ ʹଐ͞ͳ͍ঢ়ଶ ྫ௨ৗͷؔ਺΍σʔλߏ଄ɺOPOJTPMBUFE͕෇͍͍ͯΔ΋ͷ ΞΫλʔִ཭ BDUPSJTPMBUFE 

    ϝιου΍ม਺͕ΞΫλʔ͕࡞ΔυϝΠϯʹִ཭͞Ε͍ͯΔঢ়ଶ ྫBDUPSΫϥεɺJTPMBUFEύϥϝʔλΛ࣋ͭؔ਺ άϩʔόϧΞΫλʔִ཭ HMPCBMBDUPSJTPMBUFE  ϝιου΍ม਺͕άϩʔόϧΞΫλʔ͕࡞ΔυϝΠϯʹִ཭͞Ε͍ͯΔঢ়ଶ ྫ!.BJO"DUPSɺಠࣗʹఆٛͨ͠άϩʔόϧΞΫλʔ *TPMBUJPO%PNBJO ִ཭υϝΠϯ σʔλִ཭ʹΑͬͯϝιου΍ม਺Λִ཭͍ͯ͠ΔݸʑͷྖҬ
  8. 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..<constant) } } ඇִ཭ OPOJTPMBUFE ΞΫλʔִ཭ BDUPSJTPMBUFE άϩʔόϧΞΫλʔִ཭ HMPCBMBDUPSJTPMBUFE
  9. 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..<constant) } } ִ཭ڥք *TPMBUJPO#PVOEBSZ
  10. w σʔλִ཭ %BUB*TPMBUJPO  w ੩త TUBUJD ִ཭ͱಈత EZOBNJD ִ཭ͷछྨ͋Δ

    w ִ཭υϝΠϯ w σʔλִ཭ʹΑͬͯϝιου΍ม਺Λִ཭͍ͯ͠ΔݸʑͷྖҬ w ͢΂ͯͷม਺ͱؔ਺͸ɺඇִ཭ɺΞΫλʔִ཭ɺάϩʔόϧΞΫλʔִ ཭ͷ͍ͣΕ͔ʹؚ·ΕΔ w ִ཭ڥք w ִ཭υϝΠϯؒͷڥք w ִ཭ڥքΛӽ͑Δ w ҟͳΔछྨͷִ཭υϝΠϯؒͰ஋͕౉͞ΕΔ͜ͱ άϩʔ όϧΞΫ λʔִ཭ ΞΫλʔ ִ཭ ඇִ཭ ִ཭υϝΠϯ ִ཭ڥք ִ཭ڥքΛӽ͑Δ
  11. 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 }
  12. .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 } } }
  13. "UPNJD w εϨουΛʢҰॠ͚ͩʣಉظϒϩοΫ͢Δ"1* w EBUBSBDF͚ͩΛಉظతʹ๷͍͗ͨ৔߹ let counter = Atomic<Int>(0) DispatchQueue.concurrentPerform(iterations:

    10) { _ in for _ in 0 ..< 1_000_000 { counter.wrappingAdd(1, ordering: .relaxed) } } print(counter.load(ordering: .relaxed))
  14. wجຊ͸"DUPS w 4XJGU$PODVSSFODZ͸εϨουΛϒϩοΫ͠ͳ͍ࢥ૝ w "DUPS͸σουϩοΫΛى͜͞ͳ͍ ͨͩ͠ɺSBDFDPOEJUJPOΛى͜͢  w4XJGUνʔϜ΋શͯ"DUPSʹஔ͖׵͑ΒΕΔͱ͸ߟ͍͑ͯͳ͍ w ΫϦςΟΧϧηΫγϣϯ

    w BTZODΛ࢖͑ͳ͍৔߹ʢϨΨγʔίʔυɾͲ͏ͯ͠΋ಉظΞΫηε͍ͨ͠ʣ w.VUFYɺ"UPNJD ͨͩ͠ɺ4XJGUJ04Ҏ্  w J04Ҏલ͸ 04"MMPDBUFE6OGBJS-PDL͕.VUFYͷ୅ΘΓʹ࢖͑Δ
  15. ೉ͦ͠͏ͩͱࢥ͏఺ wܯࠂ΍Τϥʔ͕೉ͦ͠͏ w ϝοηʔδͷղಡ͕೉ͦ͠͏ w ܯࠂ΍Τϥʔमਖ਼ʹࠎ͕ંΕͦ͏ɻ%POUQBOJD͸ແཧ w طଘͷ໰୊͕ͳ͍ίʔυʹରͯ͠ܯࠂ΍Τϥʔ͕ग़ͯ͠·͏ જࡏతʹ͸໰୊͸͋Δ 

    w ͦ΋ͦ΋ɺͳʹΛνΣοΫͯ͠Δͷ͔͑͞ཧղग़དྷ͍ͯͳ͍ wطଘͷίʔυ͔ΒͷҠߦϓϩηε͕Θ͔Βͳ͍ w ࣗ෼ͷϓϩδΣΫτʹ߹ͬͨҠߦํ๏͕Θ͔Βͳ͍ w શମΛ$PODVSSFODZରԠͤ͞Δ͔ɺ!QSFDPODVSSFODZ౳ͷ࢑ఆରԠͤ͞Δͷ͔ w DMBTTͷѻ͍ํ w ࣮ϓϩμΫτͰͷஈ֊తͳਐΊํɻಛʹϑϨʔϜϫʔΫͷҠߦ͕ඞཁͳ৔߹ $PNCJOF͔Βͷ ஔ׵ͳͲ  wҠߦίετ͕͔͔Γͦ͏ w طଘίʔυ͕ଟ͗ͯ͢Ҡߦ͸ແཧͦ͏ɻԼखͨ͠ΒϞσϧ͔Βม͑ͳ͍ͱ͍͚ͳ͍ w ޻਺ʹݟ߹ͬͨରԠ͢ΔϝϦοτ͸͋Δͷ͔ʁ ͍͍͑ͱ ౴͑ͨํ ࣄલΞϯέʔτͷ݁Ռ
  16. ִ཭ڥքΛӽ͑ͳ͚Ε͹೉͍͜͠ͱ͸ͳ͍ .BJO"DUPS ִ཭ڥք *TPMBUJPO#PVOEBSZ 7JFX 7JFX 7JFX .PEFM 7JFX .PEFM

    .PEFM .PEFM .PEFM .BJO"DUPS಺Ͱͷ΍ΓͱΓʹ೉͠͞͸ͳ͍ (6*ΞϓϦͷଟ͘ͷ࣮૷͸ .BJO"DUPS಺ʹͱͲ·Δ
  17. 7JFX͔Β௚઀ΞΫηε͢Δঢ়ଶ͸.BJO"DUPSͰѻ͏ struct FooListView: View { @State var viewModel: FooViewModel =

    .init() var body: some View { List(viewModel.values) { value in // ... } } }
  18. ྫ.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) } }
  19. ྫෆཁʹִ཭ڥքΛӽ͑Δͱ೉͘͠ͳΔ 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ΛڬΜͩͷͰ࠶νΣοΫ // ... } }
  20. ֎ଆ͔Β࢝ΊΔ w ֎ଆ࠷্ҐϞδϡʔϧ ϝΠϯλʔήοτͳͲ  w ཧ༝ଞͷϞδϡʔϧ͔Βґଘ͞Ε͍ͯͳ͍ͨΊӨڹൣғΛ཈͑ΒΕΔ w ஫ҙઈରʹ͔͜͜Βͱ͍͏Θ͚Ͱ͸ͳ͍ w

    σʔλڝ߹҆શͰͳ͍άϩʔόϧͳঢ়ଶ΍ࣗಈͰ4FOEBCMFʹ४ڌ͍ͯ͠Δ ܕͷ͍ͤͰϓϩδΣΫτதʹܯࠂ͕େྔൃੜ͍ͯ͠Δ৔߹͸ɺͦͪΒΛ·ͣ ର৅ͱ͢Δͷ͕࠷΋ޮՌత ӳޠ൛ ೔ຊޠ൛
  21. %BUBSBDFͷओཁͳݪҼ w ϛϡʔλϒϧͳΫϥε w άϩʔόϧม਺  TUSVDUʹͰ͖ͳ͍͔ߟ͑Δ  BDUPSʹͰ͖ͳ͍͔ߟ͑Δ 

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

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

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

    04"MMPDBUFE6OGBJS-PDLΛ࢖ͬͯ4FOEBCMFʹ͢Δ  SFHJPOCBTFEJTPMBUJPOͰ৐Γ੾Δ  4FOEBCMFͷ৔߹  TUBUJDMFUDPNQVUFEQSPQFSUZʹ͢Δ  BDUPSʹִ཭͢Δ  OPOJTPMBUFE VOTBGF  MPDLΛ࢖͏  ؤுͬͯ4FOEBCMFʹ͢Δ  DPNQVUFEQSPQFSUZʹ͢Δ  BDUPSʹִ཭͢Δ  OPOJTPMBUFE VOTBGF Λ࢖͏  OPO4FOEBCMFͷ৔߹
  25.  ؤுͬͯ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ʹͰ͖ͳ͍͔ߟ͑Δ
  26. BDUPSʹ·ͭΘΔΑ͋͘ΔΤϥʔ  ར༻Օॴ͕ଟִ͗ͯ͢཭Ͱ͖ͳ͍ !QSFDPODVSSFODZ BDUPS  QSPUPDPM͕ཁٻ͢ΔBDUPSͱ ͋Δ΂͖BDUPS͕ҧ͏  QSFDPODVSSFODZDPOGPSNBODF

     OPOJTPMBUFE BTTVNF*TPMBUFE  OPOJTPMBUFE 5BTL  EFJOJU͕BDUPSʹִ཭͞Εͳ͍  EFJOJUͰඞཁͳ΋ͷʹ OPOJTPMBUFE VOTBGF Λ෇͚଍͢  EFJOJUͰඞཁͳ΋ͷΛBDUPSʹ ִ཭ͨ͠ϥούʔΛڬΉ
  27. %BUBSBDFͷओཁͳݪҼ BDUPSʹ·ͭΘΔΑ͋͘ΔΤϥʔ ར༻Օॴ͕ଟ͗ͯ͢ ִ཭Ͱ͖ͳ͍ !QSFDPODVSSFODZ BDUPS QSPUPDPM͕ ཁٻ͢ΔBDUPSͱ ͋Δ΂͖BDUPS ͕ҧ͏

    QSFDPODVSSFODZDPOGPSNBODF OPOJTPMBUFE BTTVNF*TPMBUFE OPOJTPMBUFE 5BTL EFJOJU͕ BDUPSʹ ִ཭͞Εͳ͍ EFJOJUͰඞཁͳ΋ͷʹ OPOJTPMBUFE VOTBGF Λ෇͚଍͢ EFJOJUͰඞཁͳ΋ͷΛBDUPSʹ ִ཭ͨ͠ϥούʔΛڬΉ w ϛϡʔλϒϧͳΫϥε w άϩʔόϧม਺ TUSVDUʹͰ͖ͳ͍͔ߟ͑Δ BDUPSʹͰ͖ͳ͍͔ߟ͑Δ 04"MMPDBUFE6OGBJS-PDL 4FOEBCMF SFHJPOCBTFEJTPMBUJPOͰ৐Γ੾Δ 4FOEBCMFͷ৔߹ TUBUJDMFUDPNQVUFEQSPQFSUZ BDUPSʹִ཭͢Δ OPOJTPMBUFE VOTBGF  MPDL ؤுͬͯ4FOEBCMFʹ͢Δ DPNQVUFEQSPQFSUZʹ͢Δ BDUPSʹִ཭͢Δ OPOJTPMBUFE VOTBGF Λ࢖͏ OPO4FOEBCMFͷ৔߹
  28. ৄ͘͠͸͜͜ΛΫϦοΫ ྫҟͳΔ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}}
  29. ྫҟͳΔ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ͷཧղΛਂΊΔ > Τϥʔ(ܯࠂ)ͷௐ΂ํ ৄ͘͠͸͜͜ΛΫϦοΫ ࣮ࡍʹग़ྗ͞ΕΔจݴͱಉ͡
  30. w4XJGU$PODVSSFODZΛཧղ͢Δ w 4XJGU.JHSBUJPO(VJEFΛಡΉ w 88%$ͷηογϣϯಈը w αϯϓϧίʔυΛࢼ͢ w ެࣜυΩϡϝϯτΛಡΉ w

    Τϥʔ΍ܯࠂͷௐ΂ํ w TXJGUMBOHTXJGUϦϙδτϦͷςετͰಉ͡ϝοηʔδ͕ग़ ྗ͞Ε͍ͯΔςετέʔεΛ୳ͯ͠ΈΔ
  31. 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 {}
  32. 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Ҏ߱ͷؾʹͳΔ৽ػೳ ࣄલΞϯέʔτͷ݁Ռ ޙճ͠Ͱ΋Αͦ͞͏ʁ