Internals of node.js. How does it actually work

扶醉桌前 提交于 2019-11-30 01:52:55

Node.js doesn't really manage any of this quite as you speculated. It instead relies on the OSs to do most of the async IO. It uses select/epoll/kqueue depending on the operating system. "They" just put a call out and the OS calls back with a stream, chunks, etc... As far as the evented portion of it, this is built into V8, it does all the work tieing callbacks to specific events same as it does in the browser. Finally, you can look into libuv, which was written along with node and is now all maintained by Joyent. It's open source on Github so you can browse through the code if you really want the details =D

I highly suspect that Node.JS goes the same route as Twisted and uses only non-blocking IO and greenlets. OS threads seem pretty inefficient for this sort of thing.

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