事件循环,libuv和v8引擎之间的关系 [英] Relationship between event loop,libuv and v8 engine

查看:953
本文介绍了事件循环,libuv和v8引擎之间的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习Node.js的架构。我有以下问题。

I am learning through the architecture of Node.js. I have following questions.


  1. 事件循环是libuv还是v8的一部分?

  2. 是事件排队事件循环的一部分?是由libuv或v8引擎或事件循环本身生成的事件队列吗?

  3. libuv和v8引擎之间的连接是什么?

  4. 如果事件循环是单线程,libuv是否会进入图片来创建多个线程来处理文件I / O?

  5. 浏览器是否有事件循环机制或只是Node.js吗?

  1. Is event loop a part of libuv or v8?
  2. Is event queue a part of event loop? are event queue generated by libuv or v8 engine or event loop itself?
  3. What is the connection between libuv and v8 engine?
  4. If event loop is single threaded, does libuv come into picture to create multiple threads to handle File I/O?
  5. Does browsers have event loop mechanism or just Node.js does?


推荐答案


  1. 事件循环首先是一个高级概念这是JavaScript编程模型的基本组成部分。实际上,每个V8嵌入器都需要实现一个事件循环。 V8提供了一个默认实现,嵌入器可以替换或扩展。

  1. The event loop is, first and foremost, a high-level concept that's a fundamental part of the JavaScript programming model. Practically, every V8 embedder needs to implement an event loop. V8 provides a default implementation, which embedders can replace or extend.

我不明白这个问题。 (我猜答案是是,但事件循环和事件队列之间有什么区别?)

I don't understand the question. (I guess the answer is "yes", but what's the difference between "event loop" and "event queue"?)

无。 (除了Node.js使用两者。)

None. (Except that Node.js uses both.)

是的,事件循环是单线程的。

Yes, the event loop is single-threaded.

是的,浏览器也有一个事件循环(参见问题1)。

Yes, browsers have an event loop too (see question 1).

这篇关于事件循环,libuv和v8引擎之间的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆