术语


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

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

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.

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