Do await statements unblock synchronously?

Mark Miller erights at gmail.com
Mon Apr 11 20:36:39 UTC 2016


On Mon, Apr 11, 2016 at 9:31 PM, Mark S. Miller <erights at google.com> wrote:

> Not necessarily "the next tick", but some future tick. Definitely not in
> this tick or the tick in which the promise is resolved.
>

Meant: "or the tick in which the promise is settled."



> Definitely in its own tick.
>
> And yes, engines can always do whatever unobservable optimizations they
> want.
>
>
> On Mon, Apr 11, 2016 at 6:00 PM, Jordan Harband <ljharb at gmail.com> wrote:
>
>> As I understand it, `await` always fires in the next tick, if it's
>> observable.
>>
>> The opportunity to optimize that to "same tick" exists if an engine can
>> prove it's not observable.
>>
>> On Mon, Apr 11, 2016 at 9:54 AM, Andrea Giammarchi <
>> andrea.giammarchi at gmail.com> wrote:
>>
>>> > I suppose I'm asking for cases where the await statement's promise is
>>> unresolved.
>>>
>>> isn't that a "forever pending"? then AFAIK it should "forever await" ...
>>> right?
>>>
>>> On Mon, Apr 11, 2016 at 5:50 PM, /#!/JoePea <joe at trusktr.io> wrote:
>>>
>>>> Is code that follows an await statement supposed to get executed in
>>>> the same tick in which the statement's awaited promise is resolved?
>>>> F.e.:
>>>>
>>>> ```js
>>>> let resolve = null
>>>> const somePromise = new Promise(r => resolve = r)
>>>>
>>>> ~async function() {
>>>>   await somePromise
>>>>   doSomething()
>>>> }()
>>>>
>>>> // ... time passes
>>>> resolve()
>>>> ```
>>>>
>>>> Should `doSomething()` fire in that same tick as when `resolve()` is
>>>> called? I already know that if this is true, there's at least one
>>>> exception: `await Promise.resolve()`, in that the await statement must
>>>> still defer to a future tick even though the given Promise is already
>>>> resolved. I suppose I'm asking for cases where the await statement's
>>>> promise is unresolved.
>>>>
>>>> - Joe
>>>> _______________________________________________
>>>> es-discuss mailing list
>>>> es-discuss at mozilla.org
>>>> https://mail.mozilla.org/listinfo/es-discuss
>>>>
>>>
>>>
>>> _______________________________________________
>>> es-discuss mailing list
>>> es-discuss at mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>>>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
>
> --
>     Cheers,
>     --MarkM
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
  Cheers,
  --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160411/bc20350e/attachment.html>


More information about the es-discuss mailing list