[whatwg] navigator.yield()? (Was: localStorage + worker processes)

On Tue, 24 Mar 2009, Robert O'Callahan wrote:
> 
> I think a better construct might be some sort of "yield" which 
> explicitly returns to a (nested) browser event loop and basically acts 
> as a script completion point. Even browsers that only use a single 
> thread can run the event loop there so that testing in those browsers 
> will reveal bugs.

On Mon, 23 Mar 2009, Jeremy Orlow wrote:
>
> I really like the idea of some generic yield, though I wonder if there's 
> some reason it hasn't been added earlier.  People have been using the 
> setTimeout(..., 0) trick for a while to get around slow script warnings 
> (and general unresponsiveness)...so surely something like this must have 
> come up before?  If so, what were the drawbacks?

The obvious problem is that a naive implementation could easily end up 
with a stack overflow, if it didn't pop the current script off the stack 
and use the "real" event loop each time.

I would be very happy to add a "navigator.yield()" method that basically 
causes the current script to be turned into a continuation and requeued on 
the event loop. It would make a lot of scripts a lot easier. I imagine the 
implementation burden would be pretty high though.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Monday, 23 March 2009 14:45:00 UTC