(Taking off my review manager hat)
This happens because Task.init
and Task.detached
currently take @Sendable
closures. This proposal does not change the semantics of what you're allowed to capture in a @Sendable
closure.
To enable transferring a disconnected region into a Task
, we would need the transferring
parameter future direction and adoption of transferring parameters for the Task.init
and Task.detached
closure parameters.
To clarify, are you talking about creating an AsyncSequence
of non-Sendable
elements, then passing it across isolation boundaries, then iterating over it? Or are you talking about the general Sendable
issues with calling AsyncIterator.next()
from an actor-isolated context?
If it's the latter, I think that warrants a separate discussion. I noted in the pitch thread that this proposal alone cannot solve the issues with calling AsyncIterator.next()
from an actor-isolated context:
My personal opinion is that AsyncIterator.next()
should use isolation inheritance so that the function is isolated to whatever context called it, and the the iterator is never passed across isolation boundaries. I know that other people have different opinions, and there are a few alternative approaches to consider, which is why I think it warrants a separate discussion.