Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Feedback Why Promise<T> doesn't use AsyncMethodBuilder?

Discussion in 'Game Foundation' started by RamType0, Sep 14, 2020.

  1. RamType0

    RamType0

    Joined:
    Sep 11, 2018
    Posts:
    57
  2. antoine-agthe_unity

    antoine-agthe_unity

    Unity Technologies

    Joined:
    Jun 6, 2019
    Posts:
    7
    Hello @RamType0
    Totally agree that the
    async
    /
    await
    pattern is really confortable and intuitive.

    I might have a good news for you: this approach is currently studied and we have a local branch of our project with a similar solution, that works.
    We'll likely provide this pattern, as soon as we've tested all the edge cases.
    The only thing I cannot give you, in the exact date of this to be released.

    That being said, the solution is not totally allocation free, as the runtime builds and instantiates a state machine when the
    async
    call is necessary.
    We don't have any control on this instantiation of this state machine at package level, so they is still a small cost when using
    async
    /
    await
    (even with
    UniTask
    ).
     
    mingz-unity, mk0a1a and erika_d like this.
  3. RamType0

    RamType0

    Joined:
    Sep 11, 2018
    Posts:
    57
    That's a really good news!

    What you saying is maybe like implementation of async ValueTask.
    It only avoids allocate when it completed synchronously.
    But UniTask avoids allocate even when async call is necessary.
    https://github.com/Cysharp/UniTask#pooling-configuration
    Maybe this article also helps you.
    https://devblogs.microsoft.com/dotnet/async-valuetask-pooling-in-net-5/
     
    erika_d likes this.
unityunity