术语


【Terminology】

异步资源表示一个与回调关联的对象。这个回调可能会被多次调用,例如 net.createServer() 中的 'connection' 事件,或者只调用一次,例如 fs.open()。资源也可能在回调被调用之前就被关闭。AsyncHook 并不会明确区分这些不同的情况,而是将它们表示为资源这一抽象概念。

【An asynchronous resource represents an object with an associated callback. This callback may be called multiple times, such as the 'connection' event in net.createServer(), or just a single time like in fs.open(). A resource can also be closed before the callback is called. AsyncHook does not explicitly distinguish between these different cases but will represent them as the abstract concept that is a resource.】

如果使用 Worker,每个线程都有独立的 async_hooks 接口,并且每个线程将使用一组新的异步 ID。

【If Workers are used, each thread has an independent async_hooks interface, and each thread will use a new set of async IDs.】