What is the relationship between the async / await pattern and the continuation?

I am wondering what is the relationship between the async / await pattern (as is known from Scala, F #, C #, etc.) and continuations:

  • Is the async / await pattern a limited subset of full-blown continuations? (If this is true, how is the sequel more expressive?)
  • Are continuations the only one possible implementation method for async / await ? (If true, what are other implementation approaches?)
  • Or async / await and extensions of only orthogonal concepts, where the only common thing is that they both allow abstraction of the flow of the control flow / flow?
+7
asynchronous concurrency continuations delimited-continuations async-await
source share
1 answer

I would say that the relationship between the two is async - await - these are the programming languages ​​of the technique that allow you to write code that looks synchronous (for example, there are no explicit delegates to continue), but it actually runs asynchronously. This is achieved by creating an object that represents the current state of the function's execution and registers this as a continuation of the expected operation.

In short, async - await uses continuations.

Is the async / await pattern a limited subset of full-blown continuations? (If true, how are the sequels more expressive?)

You could say that. Continuations are a more general concept, async - await just uses them to achieve asynchrony.

For example, in continuation programming, you can implement exception handling by having two extensions for each operation: one for success and one for failure. This use of continuations has nothing to do with async - await (you would have to write each continuation explicitly, perhaps like a lambda).

Is there only one possible implementation method for async / await ? (If true, what are other implementation approaches?)

I would say that the concept of continuation is pretty important for async - await .

The main idea of async - await is to terminate this function and resume it later. And for this you need some kind of object that can be used for this renewal. This is precisely the continuation.

+4
source share

All Articles