Skip to content

Commit d57cf85

Browse files
committed
[Changelog] add Distributed Actors
1 parent 13cc8b3 commit d57cf85

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,36 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
55

66
## Swift 5.7
77

8+
* [SE-0336][]:
9+
10+
It is now possible to declare `distributed actor` and `distributed func`s inside of them.
11+
12+
Distributed actors provide stronger isolation guarantees than "local" actors, and enable additional checks to be made on return types and parameters of distributed methods, e.g. checking if they conform to `Codable`. Distributed methods can be called on "remote" references of distributed actors, turning those invocations into remote procedure calls, by means of pluggable and user extensible distributed actor system implementations.
13+
14+
Swift does not provide any specific distributed actor system by itself, however, packages in the ecosystem fulfil the role of providing those implementations.
15+
16+
```swift
17+
distributed actor Greeter {
18+
var greetingsSent = 0
19+
20+
distributed func greet(name: String) -> String {
21+
greetingsSent += 1
22+
return "Hello, \(name)!"
23+
}
24+
}
25+
26+
func talkTo(greeter: Greeter) async throws {
27+
// isolation of distributed actors is stronger, it is impossible to refer to
28+
// any stored properties of distributed actors from outside of them:
29+
greeter.greetingsSent // distributed actor-isolated property 'name' can not be accessed from a non-isolated context
30+
31+
// remote calls are implicitly throwing and async,
32+
// to account for the potential networking involved:
33+
let greeting = try await greeter.greet(name: "Alice")
34+
print(greeting) // Hello, Alice!
35+
}
36+
```
37+
838
* The compiler now emits a warning when a non-final class conforms to a protocol that imposes a same-type requirement between `Self` and an associated type. This is because such a requirement makes the conformance unsound for subclasses.
939

1040
For example, Swift 5.6 would allow the following code, which at runtime would construct an instanec of `C` and not `SubC` as expected:
@@ -9034,6 +9064,7 @@ Swift 1.0
90349064
[SE-0337]: <https://github.com/apple/swift-evolution/blob/main/proposals/0337-support-incremental-migration-to-concurrency-checking.md>
90359065
[SE-0335]: <https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md>
90369066
[SE-0341]: <https://github.com/apple/swift-evolution/blob/main/proposals/0341-opaque-parameters.md>
9067+
[SE-0336]: <https://github.com/apple/swift-evolution/blob/main/proposals/0336-distributed-actor-isolation.md>
90379068

90389069
[SR-75]: <https://bugs.swift.org/browse/SR-75>
90399070
[SR-106]: <https://bugs.swift.org/browse/SR-106>

test/Distributed/distributed_actor_accessor_thunks_64bit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/Inputs/FakeDistributedActorSystems.swift
3-
// RUN: %target-swift-frontend -module-name distributed_actor_accessors -emit-irgen-disable-availability-checking -I %t 2>&1 %s | %IRGenFileCheck %s -check-prefix CHECK-%target-import-type
3+
// RUN: %target-swift-frontend -module-name distributed_actor_accessors -emit-irgen -disable-availability-checking -I %t 2>&1 %s | %IRGenFileCheck %s -check-prefix CHECK-%target-import-type
44

55
// UNSUPPORTED: back_deploy_concurrency
66
// REQUIRES: concurrency

0 commit comments

Comments
 (0)