> Am 01.09.2017 um 00:04 schrieb Nathan Gray via swift-evolution > <[email protected]>: > > 1. Fixing "queue confusion" *must* be part of this proposal. The key bit of > "magic" offered by async/await over continuation passing is that you're > working in a single scope. A single scope should execute on a single queue > unless the programmer explicitly requests otherwise. Queue hopping is a > surprising problem in a single scope, and one that there's currently no > adequate solution for. > > Also consider error handling. In this code it's really hard to reason about > what queue the catch block will execute on! And what about the defer block? > > ``` > startSpinner() > defer { stopSpinner() } > do { > try await doSomeWorkOnSomeQ() > try await doSomeMoreWorkOnSomeOtherQ() > } catch { > // Where am I? > } > ``` > > Please, please, PLEASE don't force us to litter our business logic with gobs > of explicit queue-hopping code! >
In my understanding, this is the advantage of using Actors, as calling `await` on actor functions is guaranteed to continue on the queue of the calling actor. Only if you call „legacy“ non-actor async functions, you have to take care of queue hopping by yourself - as you do today.
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
