Function#fork

Jussi Kalliokoski jussi.kalliokoski at gmail.com
Mon Sep 24 06:00:20 PDT 2012


FWIW, my own primary concern is that most (all?) JS applications are driven
by an external event loop, and I suspect that many of the native API
wrappers assume that the JS state is immutable while they do their (synch)
work. This would break that expectation, assuming there's any shared state.

Cheers,
Jussi

On Mon, Sep 24, 2012 at 3:43 PM, Jussi Kalliokoski <
jussi.kalliokoski at gmail.com> wrote:

> Hello everyone,
>
> I've been thinking a lot about parallel processing in the context of
> JavaScript, and this is really a hard problem. I'm very curious to hear
> what everyone's opinions are about it's problems and so forth, but I don't
> think an open question like that will give very interesting results, so I
> have an example problem for discussion (while it seems like a bad idea to
> me, and unlikely to ever get to the language, what I want to know is
> everyone's reasoning behind their opinions whether it's for or against).
>
> What if we introduce Function#fork(), which would call the function in
> another thread that shares state with the current one (how much state it
> shares is an open question I'd like to hear ideas about, but one
> possibility is that only the function arguments are shared) using a similar
> signature to Function#call except that the first argument would be a
> callback, which would have error as its first argument (if the forked
> function throws with the given arguments, it can be controlled) and the
> return value of the forked function as the second argument.
>
>  * What are the technical limitations of this?
>  * What are the bad/good implications of this on the language users?
>  * Better ideas?
>  * etc.
>
> I have a detailed example of showing Function#fork in action [1] (I was
> supposed to make a simplified test, but got a bit carried away and made it
> do "parallel" fragment shading), it uses a simple fill-in for the
> Function#fork using setTimeout instead of an actual thread.
>
> Cheers,
> Jussi
>
> [1] https://gist.github.com/3775697
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120924/ad2ad32f/attachment.html>


More information about the es-discuss mailing list