Re: Web workers: synchronously handling events

On Sun, Dec 26, 2010 at 4:29 PM, Glenn Maynard <glenn@zewt.org> wrote:
> Havn't been able to find this in the spec: is there a way to allow
> processing messages synchronously during a number-crunching worker
> thread?

Yes, by pausing every once in a while with setTimeout and letting the
event loop spin.

Doing anything else would break javascript's appearance of single-threadedness.

I agree that it's not particularly nice to write your algorithms like
this, but it's already familiar to any js dev who uses any algorithm
with significant running time.  If we were to fix this, it needs to be
done at the language level, because there are language-level issues to
be solved that can't be hacked around by a specialized solution.

~TJ

Received on Tuesday, 28 December 2010 20:06:54 UTC