A sequence problem of different stages in nodejs event loop.

introduced event loop in ides/event-loop-timers-and-nexttick/" rel=" nofollow noreferrer "> The Node.js Event Loop, Timers, and process.nextTick () article

The concept of

and its respective stages (phase)

  1. close callbacks
  2. check
  3. poll
  4. idle,prepare
  5. pending callbacks
  6. timers

combined with the schematic diagram given in the article

clipboard.png

:


clipboard.png

seems to express the opposite order of execution:

6 -> 5 -> 4 -> 3 -> 2-> 1

but because in the same iCompact cycle

// immediate  timeout 
$ node timeout_vs_immediate.js
immediate
timeout

$ node timeout_vs_immediate.js
immediate
timeout

so are these stages prioritized or not? If there is? What is right? Is there any conflict between the description and the icon in the document? (that is, I am concerned about English

Is there a problem with the understanding of

? )

Mar.15,2021

A little knowledge is not easy to answer you, after all, have not read the source code, this article should be what you need.
event loop in nodejs

here are two lines of code related to the problem in the poll source code of the article

    while (!QUEUE_EMPTY(&loop->watcher_queue)) {

    //timeoutuv_loop
    if (no_epoll_wait != 0 || (sigmask != 0 && no_epoll_pwait == 0)) {
Menu