Bringing setTimeout to ECMAScript

Brendan Eich brendan at mozilla.com
Sun Mar 20 10:49:12 PDT 2011


On Mar 20, 2011, at 7:18 AM, David Bruant wrote:

> Le 20/03/2011 14:33, Jorge Chamorro a écrit :
>> 
>> On 20/03/2011, at 13:51, Jorge wrote:
>>> So given 2 timers, expiring at t0 and t1 with t0 < t1, if Date.now() is >= t0 and >= t1, I would expect t0 to be serviced first, yes.
> The difference is that the system can understand what is your expectation as a user when you've clicked twice. Both click are clearly sequenced. For timers, the non-determinism due to the computation time of computea and computeb prevents you from /expecting/ anything.

There's no non-determinism in the order in which f1 and f2 were set as timeouts. The setTimeout(f1, 1000) call happens-before setTimeout(f2, 0), deterministically.

The issue here is resolved by breaking ties by inserting after all timers with the same deadline.

/be

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110320/7c027619/attachment.html>


More information about the es-discuss mailing list