Bringing setTimeout to ECMAScript
Mark S. Miller
erights at google.com
Fri Mar 18 21:24:44 PDT 2011
On Fri, Mar 18, 2011 at 4:26 PM, Brendan Eich <brendan at mozilla.com> wrote:
> On Mar 18, 2011, at 9:25 AM, Wes Garland wrote:
>
> > Right: the barrier to setTimeout functionality is that ECMAscript does
> not define a concurrency model.
> >
> > If we can define a concurrency model, then we can build setTimeout.
>
> See my previous reply. JS with setTimeout has only pseudo-concurrency via
> time-deferred script executions or function calls. There's nothing
> concurrent in a racy sense there.
>
>
> > Two things off the top of my head to consider:
> > - timer granularity
>
> This is an interop issue, mostly due to stupid benchmarks that degenerate
> to measuring whether the browser clamps at 10ms or 4ms. It is also now a
> standard: 4ms.
>
> Various implementors have found that setTimeout(f, 0) that calls f
> immediately "breaks the web" (or at least the New York Times site).
> Similarly, waiting an event loop turn seems to break the web. By testing,
> 4ms has been arrived at. I welcome fresher data.
>
Is this 4ms codified in spec language somewhere? I couldn't find it by
casual searching.
What about setTimeout(thunk, 0.00001) ? In other words, is the rule
actualTimeout = max(requestedTimeout, 4)
or
actualTimeout = requestedTimeout || 4
?
>
>
> > - forbidding eval-like syntax
>
> What problem are you solving?
>
>
> > OTOH, if we have an event-loop system with conditionals, we might not
> need setTimeout because it would be trivial to build from primitives. But it
> might be a handy interface if ES starts to go toward the "batteries
> included" model.
>
> What do you mean by conditionals? If you mean condition variables, JS will
> never grow to include shared-mutable-state threads. That would happen not
> only over my dead body, but the rest of TC39's. We'd fight back, so watch
> out.
>
+1. Add my body to that list ;).
>
> /be
> _______________________________________________
> 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/20110318/6a1ca614/attachment.html>
More information about the es-discuss
mailing list