2 ms·
Polling loops are completely different from callbacks. What I described uses functions to read partial or complete results, and functions that indicate if ther
by marcosdumay 6y ago
Polling 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.