Re: Task Queues as a primitive

(Cc'd Domenic, as he has been pushing this for a while...)


On Monday, July 1, 2013 at 4:37 PM, François REMY wrote:

> > The HTML spec speaks a lot about task queues [1]
> > and "spin the event loop" [2], but there are only
> > limited ways for devs to hook into those today.
> >  
> > Would be nice if there was some primitive that
> > allowed JS developers to hook into the loop without
> > relying on hacks like setTimeout and MutationObserver.
> >  
> > It would also be nice to see what is in those task queues
> > (ordering, etc) and in which order the task queues are
> > processed.
> >  
> > Thoughts?
>  
> Browser will probably never let you look at what they're going to do next,  
> because that would reveal much of their internal behavior, may be decided in  
> function of what you're doing and how much time it took, and may change  
> between releases (and therefore causing bugs if you act based on this  
> information).

True.   
>  
> However, it seems it's already possible to build a JS-based priority queue  
> by using the setImmediate()


Note that this is IE only right now. But good to know at least someone here is using IE and watching what is going on in Microsoft land :)
  
> hook and a custom Scheduler interface, as  
> demonstrated in WinJS 2.0 [1]. Basically, they're using priority bins to  
> influence the order of JS-based async tasks by managing them in a scheduler  
> that will act as a gateway from the native event loop to the JS waiting  
> tasks.

Neat. Great to hear there is a proof of concept already running based on setImmidiate.    
> The source code of WinJS is available but I've not downloaded the 2.0  
> preview version so I can't give more insight about it (and, in particular,  
> if they used any other API than setImmediate to hook into the event queue).
>  

Would be interesting to see. Can we get someone form Microsoft to join this list?  

BTW:  
Some related bugs (promises and ES related):
https://www.w3.org/Bugs/Public/show_bug.cgi?id=22296#c7

If we want this in Gecko:
https://bugzilla.mozilla.org/show_bug.cgi?id=686201

If we want this in Webkit:  
http://code.google.com/p/chromium/issues/detail?id=146172

Kind regards,
Marcos  

Received on Monday, 1 July 2013 16:12:49 UTC