You should take a look at https://github.com/xk/node-threads-a-gogo
It lets you write computationally expensive functions in JS, and execute
them in separate threads. It does it with isolates. V8 won't let you invoke
a JS function directly from another thread.
On Tuesday, August 28, 2012 2:47:10 PM UTC+2, Shea Levy wrote:
>
> Hello,
>
> I would like to write a javascript wrapper around uv_queue_work to deal
> with the case of computationally-expensive functions that shouldn't run in
> the event loop. While obviously this is potentially dangerous, well-written
> code could ensure that the callback called does not touch any state that
> could also potentially be viewed in parallel in the event loop. An example
> might be:
>
> function addInBackground(a,b,cb) {
> var add;
> add = function() {
> return a + b;
> }
> uv_queue_work(add,cb);
> }
>
> I know that in my naive guess on how threading could work, this particular
> usage should be safe. My question is: under the hood, is it possible that
> calling the 'add' callback from the work_cb function of uv_queue_work
> manipulates some v8 state in an unsafe way?
>
> Thanks,
> Shea
>
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en