What is the different between JavaScript Event loop and Node.js Event loop?

时光毁灭记忆、已成空白 提交于 2019-12-03 09:32:27

What's the difference between those two event loops?

Nothing. Nodejs is the JavaScript engine1.

1: Or rather, one of them, there are other engines implementing the same language and the same event loop concept.

Is there any image to introduce it more clearly?

There are many. But I think an animation is better :-) This jsconf talk by Philip Roberts is praised everywhere.

The Nodejs event loop is implemented differently than the browser based event loop.

This is a point of huge confusion in the Nodejs community.

While Nodejs uses the Google V8 as it's runtime, it does not used V8 to implement the event loop.

Nodejs uses the Libuv library (written in C++) to implement the event loop.

The digram you have above, which works for the JS event loop, is not the same for the Nodejs event loop.

There are three references you should study in order to fully understand the Nodejs event loop:

  1. https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/
  2. http://docs.libuv.org/en/v1.x/design.html
  3. https://www.youtube.com/watch?v=sGTRmPiXD4Y
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!