mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 21:58:48 +02:00
async_hooks: remove deprecated API
PR-URL: https://github.com/nodejs/node/pull/17147 Refs: https://github.com/nodejs/node/pull/16972 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
f3b12aa4c2
commit
1cc6b993b9
5 changed files with 6 additions and 94 deletions
|
@ -1,14 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
const errors = require('internal/errors');
|
||||
const internalUtil = require('internal/util');
|
||||
const async_wrap = process.binding('async_wrap');
|
||||
const internal_async_hooks = require('internal/async_hooks');
|
||||
|
||||
// Get functions
|
||||
// Only used to support a deprecated API. pushAsyncIds, popAsyncIds should
|
||||
// never be directly in this manner.
|
||||
const { pushAsyncIds, popAsyncIds } = async_wrap;
|
||||
// For userland AsyncResources, make sure to emit a destroy event when the
|
||||
// resource gets gced.
|
||||
const { registerDestroyHook } = async_wrap;
|
||||
|
@ -17,10 +13,9 @@ const {
|
|||
getHookArrays,
|
||||
enableHooks,
|
||||
disableHooks,
|
||||
// Sensitive Embedder API
|
||||
// Internal Embedder API
|
||||
newUid,
|
||||
initTriggerId,
|
||||
setInitTriggerId,
|
||||
emitInit,
|
||||
emitBefore,
|
||||
emitAfter,
|
||||
|
@ -204,18 +199,6 @@ class AsyncResource {
|
|||
}
|
||||
|
||||
|
||||
function runInAsyncIdScope(asyncId, cb) {
|
||||
// Store the async id now to make sure the stack is still good when the ids
|
||||
// are popped off the stack.
|
||||
const prevId = executionAsyncId();
|
||||
pushAsyncIds(asyncId, prevId);
|
||||
try {
|
||||
cb();
|
||||
} finally {
|
||||
popAsyncIds(asyncId);
|
||||
}
|
||||
}
|
||||
|
||||
// Placing all exports down here because the exported classes won't export
|
||||
// otherwise.
|
||||
module.exports = {
|
||||
|
@ -226,61 +209,3 @@ module.exports = {
|
|||
// Embedder API
|
||||
AsyncResource,
|
||||
};
|
||||
|
||||
// Deprecated API //
|
||||
|
||||
Object.defineProperty(module.exports, 'runInAsyncIdScope', {
|
||||
get: internalUtil.deprecate(function() {
|
||||
return runInAsyncIdScope;
|
||||
}, 'async_hooks.runInAsyncIdScope is deprecated. ' +
|
||||
'Create an AsyncResource instead.', 'DEP0086')
|
||||
});
|
||||
|
||||
Object.defineProperty(module.exports, 'newUid', {
|
||||
get: internalUtil.deprecate(function() {
|
||||
return newUid;
|
||||
}, 'async_hooks.newUid is deprecated. ' +
|
||||
'Use AsyncResource instead.', 'DEP0085')
|
||||
});
|
||||
|
||||
Object.defineProperty(module.exports, 'initTriggerId', {
|
||||
get: internalUtil.deprecate(function() {
|
||||
return initTriggerId;
|
||||
}, 'async_hooks.initTriggerId is deprecated. ' +
|
||||
'Use the AsyncResource default instead.', 'DEP0085')
|
||||
});
|
||||
|
||||
Object.defineProperty(module.exports, 'setInitTriggerId', {
|
||||
get: internalUtil.deprecate(function() {
|
||||
return setInitTriggerId;
|
||||
}, 'async_hooks.setInitTriggerId is deprecated. ' +
|
||||
'Use the triggerAsyncId parameter in AsyncResource instead.', 'DEP0085')
|
||||
});
|
||||
|
||||
Object.defineProperty(module.exports, 'emitInit', {
|
||||
get: internalUtil.deprecate(function() {
|
||||
return emitInit;
|
||||
}, 'async_hooks.emitInit is deprecated. ' +
|
||||
'Use AsyncResource constructor instead.', 'DEP0085')
|
||||
});
|
||||
|
||||
Object.defineProperty(module.exports, 'emitBefore', {
|
||||
get: internalUtil.deprecate(function() {
|
||||
return emitBefore;
|
||||
}, 'async_hooks.emitBefore is deprecated. ' +
|
||||
'Use AsyncResource.emitBefore instead.', 'DEP0085')
|
||||
});
|
||||
|
||||
Object.defineProperty(module.exports, 'emitAfter', {
|
||||
get: internalUtil.deprecate(function() {
|
||||
return emitAfter;
|
||||
}, 'async_hooks.emitAfter is deprecated. ' +
|
||||
'Use AsyncResource.emitAfter instead.', 'DEP0085')
|
||||
});
|
||||
|
||||
Object.defineProperty(module.exports, 'emitDestroy', {
|
||||
get: internalUtil.deprecate(function() {
|
||||
return emitDestroy;
|
||||
}, 'async_hooks.emitDestroy is deprecated. ' +
|
||||
'Use AsyncResource.emitDestroy instead.', 'DEP0085')
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue