You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the event loop graph is in the top down order,which make me confuse the poll phase.
if say poll phase like a moniter,which kick off the cycyle, loop and execute the callback in the phase may be most clear。
This phase executes callbacks for some system operations such as types of TCP errors.
Unless I'm misunderstanding something, it's the poll phase that "executes almost all callbacks with the exception of close callbacks, the ones scheduled by timers, and setImmediate()".
This seems to be confirmed in the libuv doc on the I/O loop which says this regarding the poll phase (#8 in the doc):
All I/O related handles that were monitoring a given file descriptor for a read or write operation get their callbacks called at this point.
Perhaps the Node.js doc should change the phase names to be more in sync with the libuv doc.
I/O callbacks could be renamed to "pending I/O callbacks"
poll could be renamed to "poll for I/O"
So the Phases Overview would look more like this:
timers: this phase executes callbacks scheduled by setTimeout() and setInterval().
pending I/O callbacks: executes I/O callbacks deferred to the next loop iteration.
idle, prepare: only used internally.
poll for I/O: retrieve new I/O events; execute I/O related callbacks (almost all with the exception of close callbacks, the ones scheduled by timers, and setImmediate()); node will block here when appropriate.
@amandeepmittal I don't think so. process.nextTick() gets it's own section in the doc because it's technically not part of the event loop. It has its own queue that is processed after each phase.
I created PR #1603. I simplified "pending I/O callbacks" to "pending callbacks" and left the name of the "poll" phase alone since it was referred to in other places.
Activity
zzuligy commentedon Feb 23, 2018
i think this is clear
fhemberger commentedon Feb 24, 2018
/cc @evanlucas
amandeepmittal commentedon Mar 15, 2018
@zzuligy But then where will you put the retrieval of I/O events?
dmcghan commentedon Mar 17, 2018
I think the confusion comes from another part of the doc being wrong. In the Phases Overview section, the I/O Callbacks bullet states:
However, in the Phases Detail > I/O Callbacks section, the detail states:
Unless I'm misunderstanding something, it's the poll phase that "executes almost all callbacks with the exception of close callbacks, the ones scheduled by timers, and setImmediate()".
This seems to be confirmed in the libuv doc on the I/O loop which says this regarding the poll phase (#8 in the doc):
Perhaps the Node.js doc should change the phase names to be more in sync with the libuv doc.
So the Phases Overview would look more like this:
setTimeout()andsetInterval().setImmediate()); node will block here when appropriate.setImmediate()callbacks are invoked here.socket.on('close', ...).fhemberger commentedon Mar 26, 2018
@dmcghan Sounds good, would you mind creating a PR for it?
amandeepmittal commentedon Mar 26, 2018
@dmcghan in
pending I/O callbacksis it good to mentionprocess.nextTick()?dmcghan commentedon Mar 26, 2018
@fhemberger Sure, will do.
@amandeepmittal I don't think so.
process.nextTick()gets it's own section in the doc because it's technically not part of the event loop. It has its own queue that is processed after each phase.dmcghan commentedon Mar 26, 2018
I created PR #1603. I simplified "pending I/O callbacks" to "pending callbacks" and left the name of the "poll" phase alone since it was referred to in other places.