Skip to content

C#'s await is not a busy-wait loop retrying periodically #4

Description

@optikos

This issue is food for thought as a design for Ada's analogue of C#'s await. Since Roslyn generates a lambda (anonymous local function) to implement an await, it is conceivable that the Ada-WinRT binding-generator tool could generate an analogous •named• (i.e., not-lambda) Ada subroutine to be called (back) when the operation completes. The lack of name is mere convenience in the lambda. Indeed even being a local function seems to be mere convenience in the lambda at the heart of await because that generated lambda seems to not absolutely crucially need to bind to any data allocated on the call-stack, other than to provide some sort of context to identify multiple concurrent invocations of the same async subroutine.

This posting on StackOverflow seems to be a lucid description of how C#'s await works (well) under the hood. Since Ada-WinRT has a code-generator at its disposal, some of the same tricks that Roslyn does as a compiler with an AST, the Ada-WinRT could conceivably (at least partially, with generated named subroutines, lay similar groundwork to) do for each async method in WinRT components.

Also, this blog posting is Kenny Kerr's intro to 1) a callback interface-mixin solution and 2) a co-routine solution to how the analogue of C#'s await could appear in C++/WinRT for an async subroutine. In variant 1, Kenny Kerr's implements<MyAsync, IAsyncAction, IAsyncInfo> seems to be similar to the callback alternative that you mention on the README.md regarding your current busy-wait-loop approach to an analogue of await in Ada.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions