Skip to content

Doesn't the quads_m() function need to be 'join'ed? #396

Open
@henish

Description

@henish

Please complete the information below:

Where is the problem?

In the example code which has the function 'quads_m()'

What is the problem?

I would expect the 'quads_m()' function to be 'await'ed or in this case 'join'ed since it is an asyn function


Please don't change anything below this point.


  • Build ID: 2016-10-05T21:47:03+0000:7e6e72a26df5c3d1ecc8feb244d6ef6d8d5dc924:3bcf6ed75043817b82363c6f7aa00050ccc8ff53
  • Page requested: /hack/async/awaitables
  • Page requested at: Thu, 08 Dec 2016 15:33:23 +0000
  • Controller: GuidePageController

Activity

acrylic-origami

acrylic-origami commented on Jan 25, 2017

@acrylic-origami

I'd say the example is misleading, but it does actually work properly without join. Since quads doesn't await anything, it finishes completely before control returns to the calling scope — it is "eagerly executed". In the end, the program is optimized such that there is no concurrency.

mofarrell

mofarrell commented on Jan 25, 2017

@mofarrell
Contributor

@acrylic-origami is right in that it correctly runs because it is eagerly executed. It would be more correct to join the result. This way the await handle is not orphaned, and possibly never executed.

To clarify:
HHVM does not run your code in parallel when you use async and await. It simply allows IO calls (like requests to a database) to be asynchronous. This means they can happen in the background and in parallel with other background tasks while your code continues to run. A well documented explanation is on the docs site.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @henish@mofarrell@AndrewDiMola@acrylic-origami

        Issue actions

          Doesn't the quads_m() function need to be 'join'ed? · Issue #396 · hhvm/user-documentation