Re: Synchronous postMessage for Workers?

On Wed, Feb 15, 2012 at 12:39 AM, Jonas Sicking <jonas@sicking.cc> wrote:

> Put it another way, when you spin the event loop, not only does your
> code need to be prepared for anything happening. All functions up the
> call stack also has to. That makes it very hard to reason about any of
> your code, not just the code that calls yieldUntil.
>

FWIW, I've used similar mechanisms, such as Lua coroutines, and it worked
well.

The message polling/blocking can be done without spinning the event loop,
of course.  It would be nice to have capabilities like running two sync
XHRs, but with message blocking, you'd be able to do that yourself with a
bit more work (spin up two workers to do the XHRs, then block on response
messages).

(By the way, don't forget the "poll a MessageChannel without blocking"
case.  It'd help things like gracefully stopping a long-running operation
rather than having to terminate the worker, which is a pattern I've used a
lot in threaded algorithms in other platforms.)

-- 
Glenn Maynard

Received on Thursday, 16 February 2012 15:07:19 UTC