this is crazy

i think that what Anand is might want to do is this:


function addAsync(no1, no2, cb)
{
    process.nextTick(function() {
        res = no1 + no2;
        cb(null, res);
    });
};

addAsync(1, 2, function(err, res) {
    console.log(res);
});

in order to queue the *intensive CPU operation of adding two numbers* for
the next tick in the event loop..


2012/6/6 Oliver Leics <oliver.le...@gmail.com>

> On Wed, Jun 6, 2012 at 3:31 PM, Anand George <mranandgeo...@gmail.com>
> wrote:
> > When I run this code I get the following output.
> >
> > 3
> > 6
> > 3.
> >
> > Any ideas why this could be happening.
>
> This happens because the code does what it has to do.
>
> > It's forcing the calling function to run again.
>
> I don't understand that. What did you expect? Maybe only one line with
> 3? But the code calls the callback two times.
>
> ???
>
> :-)
>
> --
> 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 nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to