mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
async_hooks: merge run and exit methods
PR-URL: https://github.com/nodejs/node/pull/31950 Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
This commit is contained in:
parent
f7f0441997
commit
50dd63e8ef
12 changed files with 30 additions and 215 deletions
|
@ -256,7 +256,7 @@ class AsyncLocalStorage {
|
|||
resource[this.kResourceStore] = store;
|
||||
}
|
||||
|
||||
runSyncAndReturn(store, callback, ...args) {
|
||||
run(store, callback, ...args) {
|
||||
const resource = new AsyncResource('AsyncLocalStorage');
|
||||
return resource.runInAsyncScope(() => {
|
||||
this.enterWith(store);
|
||||
|
@ -264,7 +264,7 @@ class AsyncLocalStorage {
|
|||
});
|
||||
}
|
||||
|
||||
exitSyncAndReturn(callback, ...args) {
|
||||
exit(callback, ...args) {
|
||||
if (!this.enabled) {
|
||||
return callback(...args);
|
||||
}
|
||||
|
@ -282,22 +282,6 @@ class AsyncLocalStorage {
|
|||
return resource[this.kResourceStore];
|
||||
}
|
||||
}
|
||||
|
||||
run(store, callback, ...args) {
|
||||
process.nextTick(() => {
|
||||
this.enterWith(store);
|
||||
return callback(...args);
|
||||
});
|
||||
}
|
||||
|
||||
exit(callback, ...args) {
|
||||
if (!this.enabled) {
|
||||
return process.nextTick(callback, ...args);
|
||||
}
|
||||
this.enabled = false;
|
||||
process.nextTick(callback, ...args);
|
||||
this.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Placing all exports down here because the exported classes won't export
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue