3 ms·
X does not wait on Y. It starts the task, and adds the polling interface for the task into its internal polling list. When something is available, calls the con
by marcosdumay 6y ago
X does not wait on Y. It starts the task, and adds the polling interface for the task into its internal polling list. When something is available, calls the continue interface of Y as many times as it needs, just as it does with the OS data polling.
The same happens for Y calling Z.
- int_19h 6y agoBy "wait" I mean logical wait for the result of the async operation - e.g. to use it as an input for another operation - not a blocking thread wait. What you describe sounds like callbacks to me?
- marcosdumay 6y agoPolling loops are completely different from callbacks. What I described uses functions to read partial or complete results, and functions that indicate if there is any result to read (and yeah, there must be some blocking thing to indicate whether there is any result at all available). It's something much closer to async/await, except that there is something to tell you if await will block. It is much more complex than callbacks, but it enables much higher parallelism and somewhat higher single-thread throughput. Also, runtimes with green threads already have it implemented anyway, because it's the preferred OS (any high performance OS) interface for async.
- int_19h 6y agoAsync/await is just syntactic sugar over callback-based continuations, though. And in .NET at least, you can easily tell if await will block or not, by looking at Task.IsCompleted.