Keep in mind that the nextTick hack technique still blocks your CPU.  It's
just broken up into many small parts.  If you must do something that's
truly CPU intensive, put it on a thread or another process.  Most modern
machines (even phones) have multiple CPU cores.

Interprocess communication is a fairly well solved problem in node.  There
is the built-in cluster module, there is the child_process.fork function
(somewhat like a webworker, but using a full child process).  Then in
userland there are things like dnode, hook.io, architect-protocol that
provide various levels of abstraction.

If you're writing a C addon then libuv provides a couple interfaces to do
work in a thread.  If what you doing is numerically intensive, doing it in
javascript is probably a bad idea to begin with.  Either write a node addon
and do the hard work in C or talk to another process via sockets/tcp/stdio.

On Fri, Apr 6, 2012 at 2:02 PM, mscdex <[email protected]> wrote:

> On Apr 6, 2:38 pm, Mark Hahn <[email protected]> wrote:
> > In any case, here is a loop that runs until cond is true ...
> >
> > function processOneTick() {
> >     // do work for one tick
> >     if (!cond)  setTimeout processOneTick, 0}
> >
> > processOneTick()
>
> May as well use process.nextTick() instead for that approach.
>
> --
> 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
>

-- 
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

Reply via email to