|
5 | 5 |
|
6 | 6 | ## Swift 6.2
|
7 | 7 |
|
| 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 | + |
8 | 35 | * The Swift compiler no longer diagnoses references to declarations that are
|
9 | 36 | potentially unavailable because the platform version might not be new enough
|
10 | 37 | 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
|
10788 | 10815 | [SE-0444]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
|
10789 | 10816 | [SE-0458]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0458-strict-memory-safety.md
|
10790 | 10817 | [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 |
10791 | 10819 | [#64927]: <https://github.com/apple/swift/issues/64927>
|
10792 | 10820 | [#42697]: <https://github.com/apple/swift/issues/42697>
|
10793 | 10821 | [#42728]: <https://github.com/apple/swift/issues/42728>
|
|
0 commit comments