如何从 Node.js 代码访问事件循环? [英] How to access the Event Loop from Node.js code?

查看:84
本文介绍了如何从 Node.js 代码访问事件循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可以从 Node.js 代码执行的本机函数,该函数输出一个数组或一个对象,其中包含有关当前应该在事件循环中的内容的信息?

Is there a native function that can be executed from Node.js code which outputs an array or an object containing the information about what's currently supposed to be in the Event Loop?

推荐答案

最近有a请求查看 io.js 项目中事件循环中的内容.出现了两个函数名称,在此评论中,

Recently there was a request to see what is in the event loop, in io.js project. There were two names of functions surfaced, in this comment,

  1. process._getActiveHandles() 获取仍然存活的句柄

process._getActiveRequests() 获取有关活动 libuv 请求的信息.

process._getActiveRequests() gets you info about active libuv requests.

我猜这是您可以从事件循环中收集的最多的信息.

This the most you can collect from the event loop, I guess.

注意:它们都是未记录的函数,您不能在生产代码中依赖它们.

Note: Both of them are undocumented functions and you cannot rely on them in production code.

这篇关于如何从 Node.js 代码访问事件循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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