Is it fair to say that all these points are marked with the await
keyword? I am especially wondering about a Continuation
's yield
, as that is not an async
method.
So, in a theoretical "only 1 thread" system, where I have the continuation in Task
A and another Task
B awaits
an AsyncStream
that is "driven" by the continuation, when I yield
on it, Task
A would still continue to run (and potentially fill up the stream with multiple yield
s) and Task
B would only ever be able to process the stream elements once A suspends (await
s somewhere in its execution), right? Because then the system could finally let B run on its single thread?
By the way, thanks for clearing that up and being precise, because I believe I had/have understood the system quite well by now, but the comment about it being both preemptive and cooperative had confused me.
If I got it right, one could say that while Swift concurrency builds on top of threads (which are preemptively scheduled, of course), it is itself providing cooperatively (or "cooperatively-like") scheduled tasks, which are not "affected" by the underlying threads being preemptively scheduled.