|
5 | 5 |
|
6 | 6 | ## Swift 6.0
|
7 | 7 |
|
| 8 | +* [SE-0431][]: |
| 9 | + You can now require a function value to carry its actor isolation |
| 10 | + dynamically in a way that can be directly read by clients: |
| 11 | + |
| 12 | + ```swift |
| 13 | + func apply<R>(count: Int, |
| 14 | + operation: @isolated(any) async () -> R) async -> [R] |
| 15 | + where R: Sendable { |
| 16 | + // implementation |
| 17 | + } |
| 18 | + ``` |
| 19 | + |
| 20 | + The isolation can read with the `.isolation` property, which has type |
| 21 | + `(any Actor)?`: |
| 22 | + |
| 23 | + ```swift |
| 24 | + let iso = operation.isolation |
| 25 | + ``` |
| 26 | + |
| 27 | + This capability has been adopted by the task-creation APIs in the |
| 28 | + standard library. As a result, creating a task with an actor-isolated |
| 29 | + function will now synchronously enqueue the task on the actor, which |
| 30 | + can be used for transitive event-ordering guarantees if the actor |
| 31 | + guarantees that jobs will be run in the order they are enqueued, as |
| 32 | + `@MainActor` does. If the function is not explicitly isolated, Swift |
| 33 | + still retains the right to optimize enqueues for functions that actually |
| 34 | + start by doing work with different isolation from their formal isolation. |
| 35 | + |
8 | 36 | * [SE-0423][]:
|
9 | 37 | You can now use `@preconcurrency` attribute to replace static actor isolation
|
10 | 38 | checking with dynamic checks for witnesses of synchronous nonisolated protocol
|
|
45 | 73 | The dynamic actor isolation checks can be disabled using the flag
|
46 | 74 | `-disable-dynamic-actor-isolation`.
|
47 | 75 |
|
| 76 | +* [SE-0420][]: |
| 77 | + `async` functions can now explicitly inherit the isolation of their caller |
| 78 | + by declaring an `isolated` parameter with the default value of `#isolation`: |
| 79 | + |
| 80 | + ```swift |
| 81 | + func poll(isolation: isolated (any Actor)? = #isolation) async -> [Item] { |
| 82 | + // implementation |
| 83 | + } |
| 84 | + ``` |
| 85 | + |
| 86 | + When the caller is actor-isolated, this allows it to pass isolated state |
| 87 | + to the function, which would otherwise have concurrency problems. The |
| 88 | + function may also be able to eliminate unwanted scheduling changes, such |
| 89 | + as when it can quickly return in a fast path without needing to suspend. |
| 90 | + |
48 | 91 | * [SE-0418][]:
|
49 | 92 |
|
50 | 93 | The compiler would now automatically employ `Sendable` on functions
|
@@ -10442,17 +10485,19 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
|
10442 | 10485 | [SE-0407]: https://github.com/apple/swift-evolution/blob/main/proposals/0407-member-macro-conformances.md
|
10443 | 10486 | [SE-0408]: https://github.com/apple/swift-evolution/blob/main/proposals/0408-pack-iteration.md
|
10444 | 10487 | [SE-0411]: https://github.com/apple/swift-evolution/blob/main/proposals/0411-isolated-default-values.md
|
10445 |
| -[SE-0417]: https://github.com/apple/swift-evolution/blob/main/proposals/0417-task-executor-preference.md |
10446 | 10488 | [SE-0412]: https://github.com/apple/swift-evolution/blob/main/proposals/0412-strict-concurrency-for-global-variables.md
|
10447 | 10489 | [SE-0413]: https://github.com/apple/swift-evolution/blob/main/proposals/0413-typed-throws.md
|
| 10490 | +[SE-0414]: https://github.com/apple/swift-evolution/blob/main/proposals/0414-region-based-isolation.md |
| 10491 | +[SE-0417]: https://github.com/apple/swift-evolution/blob/main/proposals/0417-task-executor-preference.md |
| 10492 | +[SE-0418]: https://github.com/apple/swift-evolution/blob/main/proposals/0418-inferring-sendable-for-methods.md |
| 10493 | +[SE-0420]: https://github.com/apple/swift-evolution/blob/main/proposals/0420-inheritance-of-actor-isolation.md |
10448 | 10494 | [SE-0422]: https://github.com/apple/swift-evolution/blob/main/proposals/0422-caller-side-default-argument-macro-expression.md
|
| 10495 | +[SE-0423]: https://github.com/apple/swift-evolution/blob/main/proposals/0423-dynamic-actor-isolation.md |
10449 | 10496 | [SE-0427]: https://github.com/apple/swift-evolution/blob/main/proposals/0427-noncopyable-generics.md
|
10450 | 10497 | [SE-0429]: https://github.com/apple/swift-evolution/blob/main/proposals/0429-partial-consumption.md
|
10451 | 10498 | [SE-0432]: https://github.com/apple/swift-evolution/blob/main/proposals/0432-noncopyable-switch.md
|
10452 |
| -[SE-0414]: https://github.com/apple/swift-evolution/blob/main/proposals/0414-region-based-isolation.md |
10453 | 10499 | [SE-0430]: https://github.com/apple/swift-evolution/blob/main/proposals/0430-transferring-parameters-and-results.md
|
10454 |
| -[SE-0418]: https://github.com/apple/swift-evolution/blob/main/proposals/0418-inferring-sendable-for-methods.md |
10455 |
| -[SE-0423]: https://github.com/apple/swift-evolution/blob/main/proposals/0423-dynamic-actor-isolation.md |
| 10500 | +[SE-0431]: https://github.com/apple/swift-evolution/blob/main/proposals/0431-isolated-any-functions.md |
10456 | 10501 | [#64927]: <https://github.com/apple/swift/issues/64927>
|
10457 | 10502 | [#42697]: <https://github.com/apple/swift/issues/42697>
|
10458 | 10503 | [#42728]: <https://github.com/apple/swift/issues/42728>
|
|
0 commit comments