Skip to content

Commit 81a06cc

Browse files
committed
[changelog] add Task.immediate SE-0472 to changelog
1 parent 396379e commit 81a06cc

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,33 @@
55
66
## Swift 6.2
77

8+
* [SE-0472][]:
9+
Introduced new `Task.immediate` and `taskGroup.addImmediateTask` APIs, which allow a task to run "immediately" in the
10+
calling context if its isolation is compatible with the enclosing one. This can be used to create tasks which execute
11+
without additional scheduling overhead, and allow for finer-grained control over where a task begins running.
12+
13+
The canonical example for using this new API is using an unstructured immediate task like this:
14+
15+
```swift
16+
func synchronous() { // synchronous function
17+
// executor / thread: "T1"
18+
let task: Task<Void, Never> = Task.immediate {
19+
// executor / thread: "T1"
20+
guard keepRunning() else { return } // synchronous call (1)
21+
22+
// executor / thread: "T1"
23+
await noSuspension() // potential suspension point #1 // (2)
24+
25+
// executor / thread: "T1"
26+
await suspend() // potential suspension point #2 // (3), suspend, (5)
27+
// executor / thread: "other"
28+
}
29+
30+
// (4) continue execution
31+
// executor / thread: "T1"
32+
}
33+
```
34+
835
* The Swift compiler no longer diagnoses references to declarations that are
936
potentially unavailable because the platform version might not be new enough
1037
when those references occur inside of contexts that are also unavailable to
@@ -10788,6 +10815,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
1078810815
[SE-0444]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
1078910816
[SE-0458]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0458-strict-memory-safety.md
1079010817
[SE-0470]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0470-isolated-conformances.md
10818+
[SE-0472]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0472-task-start-synchronously-on-caller-context.md
1079110819
[#64927]: <https://github.com/apple/swift/issues/64927>
1079210820
[#42697]: <https://github.com/apple/swift/issues/42697>
1079310821
[#42728]: <https://github.com/apple/swift/issues/42728>

0 commit comments

Comments
 (0)