In Swift 6 all task-creation APIs have been updated to use SE-0430 and SE-0431. This means from what I can see, the closure passed to task-creation APIs now are not required to be @Sendable anymore but are sending and @isolation(any).
My interest in these proposals came from this section where it is specifically mentioned, that functions that wrap the creation of Tasks are recommended to switch to @isolation(any).
Now, I've read through both proposals, however I found it hard to understand the concrete difference between the two mentioned Task creation methods. This is a snippet of the code I used to try out the differences:
Would someone help me understand compile-time and run-time differences of these two approaches? Or at least point me to resources where this might be documented.
The direct implication of the change is @isolated(any) behaviour described in the proposal:
A function value with this type dynamically carries the isolation of the function that was used to initialize it.
Plus runtime behaviour described here. Note that such closure now carries isolation parameter within it which you can access as well by operation.isolation.
It also states direct effect on Task initializers:
These APIs now all synchronously enqueue the new task directly on the appropriate executor for the task function's dynamic isolation.
There was no mechanism to express such dynamic isolation in the language before.
For @Sendable vs sending, the latter is just more relaxed constraint, allowing closures in disconnected region to be passed, while they might not be @Sendable.