Bringing setTimeout to ECMAScript

Kyle Simpson getify at gmail.com
Sat Mar 19 17:24:17 PDT 2011


> Kyle: If there was a way to determine which timers are currently queued, 
> would that solve your problem? That's probably the only thing I'm missing 
> right now from the timer api: Some array with all queued 
> timeouts/intervals. Maybe that's to prevent the clear "attack" mentioned 
> before, looping all numbers and clearing them. I don't know. But if you 
> had such an array (either with just ints, or even an object with 
> {int,time/interval,callback}) would that suffice for you? You could check 
> the list and block while there are timers left.

Well, my point was, I'd like the embedding layer not to have to implement 
that kind of logic if there's a way to avoid it. But yes, in terms of 
least-effort, that sounds like the simplest approach to essentially blocking 
on the event loop queue to wait for it to complete. However, we'd have to 
consider all such possible "events", not just timers... XHR comes to mind. 
"server-sent events" comes to mind (aka, server-to-server events). etc.


--Kyle 



More information about the es-discuss mailing list