|
5 | 5 |
|
6 | 6 | ## Swift 6.0
|
7 | 7 |
|
8 |
| - |
9 | 8 | * Swift 6 comes with a new language mode that prevents the risk of data races
|
10 | 9 | at compile time. This guarantee is accomplished through _data isolation_; the
|
11 | 10 | compiler will validate that data passed over a boundary between concurrently
|
|
22 | 21 | You can enable the Swift 6 language mode using the `-swift-version 6`
|
23 | 22 | compiler flag.
|
24 | 23 |
|
| 24 | +* [SE-0428][]: |
| 25 | + Distributed actors now have the ability to support complete split server / |
| 26 | + client systems, thanks to the new `@Resolvable` macro and runtime changes. |
| 27 | + |
| 28 | + It is now possible to share an "API module" between a client and server |
| 29 | + application, declare a resolvable distributed actor protocol with the expected |
| 30 | + API contract and perform calls on it, without knowing the specific type the |
| 31 | + server is implementing those actors as. |
| 32 | + |
| 33 | + Declaring such protocol looks like this: |
| 34 | + |
| 35 | +```swift |
| 36 | +import Distributed |
| 37 | + |
| 38 | +@Resolvable |
| 39 | +protocol Greeter where ActorSystem: DistributedActorSystem<any Codable> { |
| 40 | + distributed func greet(name: String) -> String |
| 41 | +} |
| 42 | +``` |
| 43 | + |
| 44 | +And the module structure to support such applications looks like this: |
| 45 | + |
| 46 | +``` |
| 47 | + ┌────────────────────────────────────────┐ |
| 48 | + │ API Module │ |
| 49 | + │========================================│ |
| 50 | + │ @Resolvable │ |
| 51 | + │ protocol Greeter: DistributedActor { │ |
| 52 | + ┌───────┤ distributed func greet(name: String) ├───────┐ |
| 53 | + │ │ } │ │ |
| 54 | + │ └────────────────────────────────────────┘ │ |
| 55 | + │ │ |
| 56 | + ▼ ▼ |
| 57 | +┌────────────────────────────────────────────────┐ ┌──────────────────────────────────────────────┐ |
| 58 | +│ Client Module │ │ Server Module │ |
| 59 | +│================================================│ │==============================================│ |
| 60 | +│ let g = try $Greeter.resolve(...) /*new*/ │ │ distributed actor EnglishGreeter: Greeter { │ |
| 61 | +│ try await greeter.hello(name: ...) │ │ distributed func greet(name: String) { │ |
| 62 | +└────────────────────────────────────────────────┘ │ "Greeting in english, for \(name)!" │ |
| 63 | +/* Client cannot know about EnglishGreeter type */ │ } │ |
| 64 | + │ } │ |
| 65 | + └──────────────────────────────────────────────┘ |
| 66 | +``` |
| 67 | + |
| 68 | +* [SE-0424][]: |
| 69 | + Serial executor gains a new customization point `checkIsolation()`, which can be |
| 70 | + implemented by custom executor implementations in order to provide a last resort |
| 71 | + check before the isolation asserting APIs such as `Actor.assumeIsolated` or |
| 72 | + `assertIsolated` fail and crash. |
| 73 | + |
| 74 | + This specifically enables Dispatch to implement more sophisticated isolation |
| 75 | + checking, and now even an actor which is "on a queue which is targeting |
| 76 | + another specific queue" can be properly detected using these APIs. |
| 77 | + |
25 | 78 | * [SE-0431][]:
|
26 | 79 | You can now require a function value to carry its actor isolation
|
27 | 80 | dynamically in a way that can be directly read by clients:
|
@@ -10514,6 +10567,10 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
|
10514 | 10567 | [SE-0429]: https://github.com/apple/swift-evolution/blob/main/proposals/0429-partial-consumption.md
|
10515 | 10568 | [SE-0432]: https://github.com/apple/swift-evolution/blob/main/proposals/0432-noncopyable-switch.md
|
10516 | 10569 | [SE-0430]: https://github.com/apple/swift-evolution/blob/main/proposals/0430-transferring-parameters-and-results.md
|
| 10570 | +[SE-0418]: https://github.com/apple/swift-evolution/blob/main/proposals/0418-inferring-sendable-for-methods.md |
| 10571 | +[SE-0423]: https://github.com/apple/swift-evolution/blob/main/proposals/0423-dynamic-actor-isolation.md |
| 10572 | +[SE-0424]: https://github.com/apple/swift-evolution/blob/main/proposals/0424-custom-isolation-checking-for-serialexecutor.md |
| 10573 | +[SE-0428]: https://github.com/apple/swift-evolution/blob/main/proposals/0428-resolve-distributed-actor-protocols.md |
10517 | 10574 | [SE-0431]: https://github.com/apple/swift-evolution/blob/main/proposals/0431-isolated-any-functions.md
|
10518 | 10575 | [#64927]: <https://github.com/apple/swift/issues/64927>
|
10519 | 10576 | [#42697]: <https://github.com/apple/swift/issues/42697>
|
|
0 commit comments