Sending a callback to nextTick is almost the functional equivalent of running 
it at the end of your script. They are intentionally run before the following 
event loop. Try sending a callback to setImmediate then one to nextTick. The 
later will run first.

On Friday, February 15, 2013 8:44:17 AM UTC-8, Matt Sergeant 
wrote:
> Although nextTick() now happens at the end of the event loop I believe ;-)
> 
> 
> But yeah, once you start thinking about how these things are implemented, it 
> becomes easier to understand why Node does what it does.
> 
> 
> 
> 
> On Fri, Feb 15, 2013 at 11:14 AM, Jorge Chamorro <[email protected]> 
> wrote:
> 
> 
> 
> On 15/02/2013, at 15:15, Matt wrote:
> 
> 
> 
> > I had a number of questions at work this week about how node works on a low 
> > level, so decided to create a blog post about the basics of how event loops 
> > work.
> 
> >
> 
> > I'm hoping this might help other people get more of an understanding of how 
> > Node works internally. It's not an entirely accurate reflection of the node 
> > internals, more of a general overview of how event loops work from a basic 
> > implementation standpoint.
> 
> 
> >
> 
> > http://baudehlo.wordpress.com/2013/02/14/how-an-event-loop-works/
> 
> >
> 
> > Would love to get feedback on the post.
> 
> 
> 
> The process.nextTick(ƒ) queue, more or less... :-)
> 
> 
> 
> while (someThingToDo) {
> 
> 
> 
>     var n= nextTickQueue.length;
> 
>     while (n--) nextTickQueue.shift()();
> 
> 
> 
>     var next_timeout = _run_timers();
> 
> 
> 
>     if (nextTickQueue.length) continue;
> 
>     ms_sleep(next_timeout);
> 
> }
> 
> 
> 
> --
> 
> Jorge.
> 
> 
> 
> --
> 
> --
> 
> 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
> 
> 
> 
> ---
> 
> 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 [email protected].
> 
> For more options, visit https://groups.google.com/groups/opt_out.

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

--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to