问题
What does process.nextTick
exactly mean ?
Does nextTick
mean, after callback queue pop for one element in the current phase ? Or before moving to the next phase after executing all callbacks in the current phase's queue ?
回答1:
This is described in the documentation.
nextTick
queues callbacks to be invoked at the end of the current tick. The entire queue is emptied before moving to the next tick.
Contrast with setImmediate, which queues callbacks to be invoked during the next tick.
(Yes, the names are misleading, but their behavior is that way to keep compatibility.)
来源:https://stackoverflow.com/questions/37231160/does-nexttick-means-next-phase-in-node-js-event-loop