-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zh-CN:Trans for 'Clarify when nextTickQueue is processed' #2026
Conversation
@@ -199,7 +199,7 @@ timeout | |||
|
|||
### 理解 `process.nextTick()` | |||
|
|||
您可能已经注意到 `process.nextTick()` 在关系图中没有显示,即使它是异步 API 的一部分。这是因为 `process.nextTick()` 在技术上不是事件循环的一部分。相反,无论事件循环的当前阶段如何,都将在当前操作完成后处理 `nextTickQueue`。 | |||
您可能已经注意到 `process.nextTick()` 在关系图中没有显示,即使它是异步 API 的一部分。这是因为 `process.nextTick()` 在技术上不是事件循环的一部分。相反,无论事件循环的当前阶段如何,都将在当前操作完成后处理 `nextTickQueue`。这里的一个*操作*被视作为一个从 C++ 底层处理开始过度,并且处理需要执行的 JavaScript 代码。 | |||
|
|||
回顾我们的关系图,任何时候您调用 `process.nextTick()` 在给定的阶段中,所有传递到 `process.nextTick()` 的回调将在事件循环继续之前得到解决。这可能会造成一些糟糕的情况, 因为**它允许您通过进行递归 `process.nextTick()` 来“饿死”您的 I/O 调用**,阻止事件循环到达 **轮询** 阶段。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直译 饿死
不够生动形象。。。 递归更像撑死。
直接说 阻塞I/O
会不会好一些
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I/O调用因为异步轮询不断调用process.nextTick()始终得不到调用,所以始终处于“饥饿”状态,这是对的。而是说时间轮询队列被撑死了。
我们等一下其它人看法吧,我通读此文感觉这里的确是“饿死”,是说顺序执行的I/O始终得不到机会执行。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
原文:
This can create some bad situations because it allows you to "starve" your I/O by making recursive process.nextTick() calls, which prevents the event loop from reaching the poll phase.
IMHO, 我是觉得没什么太大问题 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果没理解错的话,event loop
应该翻译成 事件循环
吧。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ref:#1804
@nodejs/nodejs-cn