Not awaiting* async*

What happens if you don’t await* and async*?

With awaits, if you skip the await, the function still gets queued and called but your function doesn’t get to know the result.

I’m seeing some behavior with await* that if I don’t await* it then the code never actually gets run. Is that the case? I guess I can always not await any actual async termination points in my tree, but I was hoping to get the same behavior.

1 Like

It’s not necessary to await* because computations are are simply inert objects, unless you are await*-ing them. So the only effect they cause is filling up memory with garbage if you don’t really use them. Nothing bad happens. If you know Haskell, this is like gadgets of type IO String, you can compose them to get bigger, sequential IO x, but they are just dormant.

Note that this is different from async, where the message (potentially to self) will be sent. This also justifies the *: meaning zero or more sends. If you don’t await* it is definitively zero :slight_smile:

1 Like

@skilesare This info is from async* release notes

WARNING: Unlike async/await:

  • an async* value has no effect unless await*-ed;
  • each await* of the same async* value repeats its effects.