NODEJS事件循环回调限制限制
Nodejs事件循环的每个周期同步清除每个阶段排队的最大回调数。
来自Nodejs网站:
当事件循环进入给定阶段时,它将执行特定于该阶段的操作,然后在该阶段队列中执行回调,直到排队用尽或最大回调数量为止。
。
事件循环阶段:计时器 - >等待回调 - >闲置,准备 - >民意调查 - >检查 - >关闭回调
例如,在民意测验阶段,限制由libuv设置:
为了防止轮询阶段饿死事件循环,libuv(实现Node.js事件循环的C库和平台的所有异步行为)在停止轮询之前也具有硬最大值(系统依赖)有关更多事件。
我的问题是:
- 我在哪里可以找到每个阶段/迭代的硬限制?
- 奖励:是否有一种程序化方法可以获取每个阶段队列的当前大小?
Every cycle of the NodeJS event loop synchronously clears a maximum number of callbacks queued for each phase.
From NodeJS website:
when the event loop enters a given phase, it will perform any operations specific to that phase, then execute callbacks in that phase's queue until the queue has been exhausted or the maximum number of callbacks has executed.
Event loop phases: timers --> pending callbacks --> idle, prepare --> poll --> check --> close callbacks
For example in the poll phase the limit is set by libuv:
To prevent the poll phase from starving the event loop, libuv (the C library that implements the Node.js event loop and all of the asynchronous behaviors of the platform) also has a hard maximum (system dependent) before it stops polling for more events.
My question is:
- Where can I find these hard limits per phase/iteration?
- Bonus: Is there a programmatic way to get the current size of each phase's queue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论