You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Working on F# compiler support for runtime-async there is an obstacle.
Conventionally high level async code is realized via computation expressions which provide async/await like syntactic sugar:
Computation expressions compile into many composed functions and lambdas. In case of runtime-async, some of those will contain AsyncHelpers.Await calls creating suspensions.
According to spec, AsyncHelpers suspending calls are legal only inside async methods. To reconcile this with nested, compositional nature of F# async expressions we try to inline the runtime-async computation expression into a single resulting async method, using F# compiler inlining. This is not always successful, more complicated constructs can fail to inline.
The alternative is to truly compose the building blocks of an async expression. The problem is, there is no public runtime-async helper for this. We can only turn the potentially suspending building blocks into async methods and compose them by simply awaiting with AsyncHelpers.Await. This is not optimal, it creates additional suspensions and ExecutionContext boundaries.
It would be great to have a helper to make a potentially suspending call (a call to a function that may call Await or transitively call other such functions) in a way that's similar to inlining. This means no suspension and no ExecutionContext boundary, just synchronously continue into the inner async method until an actual suspension is encountered.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Working on F# compiler support for runtime-async there is an obstacle.
Conventionally high level async code is realized via computation expressions which provide async/await like syntactic sugar:
Computation expressions compile into many composed functions and lambdas. In case of runtime-async, some of those will contain
AsyncHelpers.Awaitcalls creating suspensions.According to spec, AsyncHelpers suspending calls are legal only inside async methods. To reconcile this with nested, compositional nature of F# async expressions we try to inline the runtime-async computation expression into a single resulting async method, using F# compiler inlining. This is not always successful, more complicated constructs can fail to inline.
The alternative is to truly compose the building blocks of an async expression. The problem is, there is no public runtime-async helper for this. We can only turn the potentially suspending building blocks into async methods and compose them by simply awaiting with
AsyncHelpers.Await. This is not optimal, it creates additional suspensions and ExecutionContext boundaries.It would be great to have a helper to make a potentially suspending call (a call to a function that may call
Awaitor transitively call other such functions) in a way that's similar to inlining. This means no suspension and no ExecutionContext boundary, just synchronously continue into the inner async method until an actual suspension is encountered.All reactions