Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Belanger <admin@stephenbelanger.com>2020-06-10 00:50:03 +0300
committerAnna Henningsen <anna@addaleax.net>2020-06-19 18:37:26 +0300
commit646e5a471766e27e8317bb54d1fd1d2c72cffb69 (patch)
treec3a86963847b1ece3367e72725937bf79bb972b2 /lib/internal/async_hooks.js
parent59e6230a30954f78836048b581d8db61582242ef (diff)
domain: remove native domain code
With the async_hooks callback trampoline, domains no longer need any native code. With this, domains can exist in pure JavaScript. PR-URL: https://github.com/nodejs/node/pull/33801 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Diffstat (limited to 'lib/internal/async_hooks.js')
-rw-r--r--lib/internal/async_hooks.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js
index e400f24689f..fc894ebe4d7 100644
--- a/lib/internal/async_hooks.js
+++ b/lib/internal/async_hooks.js
@@ -106,8 +106,13 @@ const emitDestroyNative = emitHookFactory(destroy_symbol, 'emitDestroyNative');
const emitPromiseResolveNative =
emitHookFactory(promise_resolve_symbol, 'emitPromiseResolveNative');
-function callbackTrampoline(asyncId, cb, domain_cb, ...args) {
- if (hasHooks(kBefore))
+let domain_cb;
+function useDomainTrampoline(fn) {
+ domain_cb = fn;
+}
+
+function callbackTrampoline(asyncId, cb, ...args) {
+ if (asyncId && hasHooks(kBefore))
emitBeforeNative(asyncId);
let result;
@@ -118,7 +123,7 @@ function callbackTrampoline(asyncId, cb, domain_cb, ...args) {
result = ReflectApply(cb, this, args);
}
- if (hasHooks(kAfter))
+ if (asyncId && hasHooks(kAfter))
emitAfterNative(asyncId);
return result;
@@ -564,6 +569,7 @@ module.exports = {
emitAfter: emitAfterScript,
emitDestroy: emitDestroyScript,
registerDestroyHook,
+ useDomainTrampoline,
nativeHooks: {
init: emitInitNative,
before: emitBeforeNative,