Pardon for resurrecting such old thread but I have a question about process.nextTick: why/how does it eliminate the current stack? What happens behind the scenes?
On Tuesday, January 17, 2012 5:29:13 PM UTC-5, JoeZ99 wrote: > > I don't really know how node knows when to run a function asynchronously > or not. > > Let's say you have this piece of code. > > function gen_url(str) { > return 'http://' + str; > } > > full_url = gen_url('www.google.com'); > > In that case I'm obviously counting on the function gen_url being executed > synchronously. > > Now If I have > > function hit_mysql(query, callback) { > var mystuff = oldstuff * system_variable; > client = require('mysql').Client(); > client.query(query, callback); > } > > var one = 'one'; > hit_mysql('select ...', function(){console.log('done');}); > var two = 'two'; > > > I would expect hit_mysql to run asynchronousy. > > > How does node figure this out? I'm no "marking" any function as "sync" or > "async". Does node througfuly examine the function's body to see if > somewhere in the function body (or in the body of the functions defined in > the function body) there is some well recognized native node async call, > like setTimeout, or http.listen(), or whatever? > -- > uh, oh <http://www.youtube.com/watch?v=GMD_T7ICL0o>. > > <http://windows7sins.org/> > > -- -- 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 --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.