简体   繁体   English

Node js中如何处理事件队列?

[英]How does event queue is processed in Node js?

I am learning through the architecture of Node.js.我正在学习 Node.js 的架构。 I have following questions.我有以下问题。

1) Is event loop a part of libuv or v8? 1) 事件循环是 libuv 还是 v8 的一部分?

2) If event loop is responsible for delegating the blocking call to libuv and putting the callback to the event queue, than how does the callback present in event queue goes to call stack for execution? 2)如果事件循环负责将阻塞调用委托给libuv并将回调放入事件队列,那么事件队列中存在的回调如何进入调用堆栈执行?

3) How v8 and libuv interact with each other in Node.js? 3) v8 和 libuv 在 Node.js 中如何交互?

Diagram showing the Node Js architecture.显示 Node Js 架构的图表。

**Can anybody explain me how does v8 gets back the data from event queue to process it in the given diagram? **谁能解释一下 v8 如何从事件队列中取回数据以在给定的图表中处理它?

在此处输入图像描述

Event Loop Diagram事件循环图

Now can someone tell me which diagram shows the correct position of event loop in Node js architecture?现在有人可以告诉我哪个图表显示了 Node js 架构中事件循环的正确位置吗?

  1. Eventloop will be part of LIBUV Eventloop 将成为 LIBUV 的一部分
  2. process.nextTick() taken care by LIBUV. process.nextTick() 由 LIBUV 处理。 Eventloop internally uses timers, I/O callbacks, idle or process, poll (incoming requests), check, close I/O callback, and connect to timers. Eventloop 内部使用定时器、I/O 回调、空闲或进程、轮询(传入请求)、检查、关闭 I/O 回调和连接定时器。
  3. V8 engine takes care of connecting jscode or application to nodejs API. V8 引擎负责将 jscode 或应用程序连接到 nodejs API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM