[swift-evolution] [Concurrency] async/await + actors

Thomas tclementdev at free.fr
Fri Aug 25 03:16:54 CDT 2017


> On 25 Aug 2017, at 09:04, Marc Schlichte <marc.schlichte at googlemail.com> wrote:
> 
> 
>> Am 24.08.2017 um 22:05 schrieb Thomas via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>>:
>> 
>>> 
>>> Yes, I think it is mandatory that we continue on the callers queue after an `await ` on some actor method.
>>> 
>>> If you `await` on a non-actor-method though, you would have to changes queues manually if needed.
>>> 
>>> Any `actor` should have a `let actorQueue: DispatchQueue` property so that we can call in these cases:
>>> 
>>> ```await actorQueue.asyncCoroutine()``` as mentioned in the manifesto.
>> 
>> Wouldn't that be really confusing though? That awaiting certain methods would bring us back to the actor's queue but awaiting others would require manual queue hopping? What if the compiler was to always generate the 'await actorQueue.asyncCoroutine()' queue hopping code after awaiting on an async/actor method?
>> 
>> Thomas
>> 
> 
> I think we are not allowed to implicitly switch back to the actor's queue after awaiting non-actor methods. These might have been auto converted from Continuation-Passing-Style (CPS) to async/await style. With the `mainActor` idea from the manifesto, all existing code will run in some actor, so changing the queue semantics could break existing code.

This would only happen when the caller is an actor, which means new code, so I don't think we would be breaking any existing code.

Thomas

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170825/e3000cd7/attachment.html>


More information about the swift-evolution mailing list