Skip to content

Commit 9d16901

Browse files
committed
changelog: include isolated deinit in changelog
1 parent 61e179d commit 9d16901

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

CHANGELOG.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,48 @@
3232
}
3333
```
3434

35+
* [SE-0471][]:
36+
Actor and global actor annotated types may now declare a synchronous `isolated deinit`, which allows such deinitializer
37+
to access actor isolated state while deinitializing the actor. This enables actor deinitializers to safely access
38+
and shut down or close resources during an actors deinitialization, without explicitly resorting to unstructured
39+
concurrency tasks.
40+
41+
```swift
42+
class NonSendableAhmed {
43+
var state: Int = 0
44+
}
45+
46+
@MainActor
47+
class Maria {
48+
let friend: NonSendableAhmed
49+
50+
init() {
51+
self.friend = NonSendableAhmed()
52+
}
53+
54+
init(sharingFriendOf otherMaria: Maria) {
55+
// While the friend is non-Sendable, this initializer and
56+
// and the otherMaria are isolated to the MainActor. That is,
57+
// they share the same executor. So, it's OK for the non-Sendable value
58+
// to cross between otherMaria and self.
59+
self.friend = otherMaria.friend
60+
}
61+
62+
isolated deinit {
63+
// Used to be a potential data race. Now, deinit is also
64+
// isolated on the MainActor, so this code is perfectly
65+
// correct.
66+
friend.state += 1
67+
}
68+
}
69+
70+
func example() async {
71+
let m1 = await Maria()
72+
let m2 = await Maria(sharingFriendOf: m1)
73+
doSomething(m1, m2)
74+
}
75+
```
76+
3577
* [SE-0469][]:
3678
Swift concurrency tasks (both unstructured and structured, via the TaskGroup `addTask` APIs) may now be given
3779
human-readable names, which can be used to support debugging and identifying tasks.
@@ -10868,6 +10910,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
1086810910
[SE-0462]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0462-task-priority-escalation-apis.md
1086910911
[SE-0469]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0469-task-names.md
1087010912
[SE-0470]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0470-isolated-conformances.md
10913+
[SE-0471]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0371-isolated-synchronous-deinit.md
1087110914
[SE-0472]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0472-task-start-synchronously-on-caller-context.md
1087210915
[#64927]: <https://github.com/apple/swift/issues/64927>
1087310916
[#42697]: <https://github.com/apple/swift/issues/42697>

0 commit comments

Comments
 (0)