async_hooks: remove async_wrap from async_hooks.js
This commit removes the builtin async_wrap module from lib/async_hooks.js. The motivation for this is that lib/async_hooks.js requires lib/internal/async_hooks which also binds async_wrap. Instead of lib/async_hooks.js also binding async_wrap it now only has to require the internal async_hooks and access it's exports. There might be a very good reason for doing it the current way but the reason is not obvious to me. Hopefully someone can shed some light on this. PR-URL: https://github.com/nodejs/node/pull/19368 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
75ff301ae0
commit
8c46fa6903
@ -5,13 +5,12 @@ const {
|
||||
ERR_INVALID_ARG_TYPE,
|
||||
ERR_INVALID_ASYNC_ID
|
||||
} = require('internal/errors').codes;
|
||||
const async_wrap = process.binding('async_wrap');
|
||||
const internal_async_hooks = require('internal/async_hooks');
|
||||
|
||||
// Get functions
|
||||
// For userland AsyncResources, make sure to emit a destroy event when the
|
||||
// resource gets gced.
|
||||
const { registerDestroyHook } = async_wrap;
|
||||
const { registerDestroyHook } = internal_async_hooks;
|
||||
const {
|
||||
executionAsyncId,
|
||||
triggerAsyncId,
|
||||
@ -38,7 +37,7 @@ const {
|
||||
// Get constants
|
||||
const {
|
||||
kInit, kBefore, kAfter, kDestroy, kTotals, kPromiseResolve,
|
||||
} = async_wrap.constants;
|
||||
} = internal_async_hooks.constants;
|
||||
|
||||
// Listener API //
|
||||
|
||||
|
@ -65,11 +65,12 @@ const active_hooks = {
|
||||
tmp_fields: null
|
||||
};
|
||||
|
||||
const { registerDestroyHook } = async_wrap;
|
||||
|
||||
// Each constant tracks how many callbacks there are for any given step of
|
||||
// async execution. These are tracked so if the user didn't include callbacks
|
||||
// for a given step, that step can bail out early.
|
||||
const { kInit, kBefore, kAfter, kDestroy, kPromiseResolve,
|
||||
const { kInit, kBefore, kAfter, kDestroy, kTotals, kPromiseResolve,
|
||||
kCheck, kExecutionAsyncId, kAsyncIdCounter, kTriggerAsyncId,
|
||||
kDefaultTriggerAsyncId, kStackLength } = async_wrap.constants;
|
||||
|
||||
@ -435,6 +436,9 @@ module.exports = {
|
||||
init_symbol, before_symbol, after_symbol, destroy_symbol,
|
||||
promise_resolve_symbol
|
||||
},
|
||||
constants: {
|
||||
kInit, kBefore, kAfter, kDestroy, kTotals, kPromiseResolve
|
||||
},
|
||||
enableHooks,
|
||||
disableHooks,
|
||||
clearDefaultTriggerAsyncId,
|
||||
@ -452,4 +456,5 @@ module.exports = {
|
||||
emitBefore: emitBeforeScript,
|
||||
emitAfter: emitAfterScript,
|
||||
emitDestroy: emitDestroyScript,
|
||||
registerDestroyHook,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user