On Sat, Feb 16, 2013 at 12:00 PM, Jorge Chamorro
<[email protected]> wrote:
> On 16/02/2013, at 11:26, Trevor Norris wrote:
>
>> 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.
>
> setImmediate? In which node? So they did change the semantics of nextTick, 
> again?
>
>
> @izs, ben, bert, fedor, nathan etc: Could you please tell us how does the 
> event loop look like now, in pseudo code?
>
> while (RUN) {
>
>   dispatch setImmediateQueue();
>
>   dispatchPendingIO();
>
>   dispatchTimers();
>
>   dispatch nextTickQueue();
> }
>
> Please?
>
> TIA,
> --
> Jorge.

>From [1]:

  do {
    uv__update_time(loop);
    uv__run_timers(loop);
    uv__run_idle(loop);
    uv__run_prepare(loop);
    uv__run_pending(loop);
    uv__io_poll(loop, (mode & UV_RUN_NOWAIT ? 0 : uv_backend_timeout(loop)));
    uv__run_check(loop);
    uv__run_closing_handles(loop);
    r = uv__loop_alive(loop);
  } while (r && !(mode & (UV_RUN_ONCE | UV_RUN_NOWAIT)));

process.nextTick() is backed by an idle handle, setImmediate() by a
check handle.

One difference between uv-win and uv-unix is that close callbacks run
at separate stages.  On Windows, a handle's endgame may take several
ticks.

[1] https://github.com/joyent/libuv/blob/b6f72e5/src/unix/core.c#L288-298

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