Does nextTick means next phase in Node.js (Event Loop)?

╄→гoц情女王★ 提交于 2019-12-12 05:44:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!