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

Marc Schlichte marc.schlichte at googlemail.com
Fri Aug 25 15:07:04 CDT 2017


> Am 25.08.2017 um 19:08 schrieb Adam Kemp via swift-evolution <swift-evolution at swift.org>:
> 
> I understand what you’re saying, but I just think trying to make synchronous, blocking actor methods goes against the fundamental ideal of the actor model, and it’s a recipe for disaster. When actors communicate with each other that communication needs to be asynchronous or you will get deadlocks. It’s not just going to be a corner case. It’s going to be a very frequent occurrence.
> 
> One of the general rules of multithreaded programming is “don’t call unknown code while holding a lock”. Blocking a queue is effectively the same as holding a lock, and calling another actor is calling unknown code. So if the model works that way then the language itself will be encouraging people to call unknown code while holding locks. That is not going to go well.
> 

I would claim - without having a prove though - that as long as you don’t invoke async actor methods on weak or unowned actor references and the code is retain cycle free, no deadlocks will happen.

Cheers
Marc

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


More information about the swift-evolution mailing list