diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-11-03 13:00:24 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-11-06 13:57:55 +0100 |
commit | d80e49d6801501a0f2b93c442d5e425ed6fc73fb (patch) | |
tree | 959211f188647dab675a4980a2c0f65b9a37a34f /src/api | |
parent | 369803175307dae7fd6b983d9270619f11bd7214 (diff) | |
download | android-node-v8-d80e49d6801501a0f2b93c442d5e425ed6fc73fb.tar.gz android-node-v8-d80e49d6801501a0f2b93c442d5e425ed6fc73fb.tar.bz2 android-node-v8-d80e49d6801501a0f2b93c442d5e425ed6fc73fb.zip |
src: use callback scope for main script
This allows removing custom code for setting the current async ids
and running nextTicks.
PR-URL: https://github.com/nodejs/node/pull/30236
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/callback.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/api/callback.cc b/src/api/callback.cc index 6d4e28e1d9..bced9bb7ab 100644 --- a/src/api/callback.cc +++ b/src/api/callback.cc @@ -43,12 +43,13 @@ InternalCallbackScope::InternalCallbackScope(AsyncWrap* async_wrap) InternalCallbackScope::InternalCallbackScope(Environment* env, Local<Object> object, const async_context& asyncContext, - ResourceExpectation expect) + int flags) : env_(env), async_context_(asyncContext), object_(object), - callback_scope_(env) { - CHECK_IMPLIES(expect == kRequireResource, !object.IsEmpty()); + callback_scope_(env), + skip_hooks_(flags & kSkipAsyncHooks) { + CHECK_IMPLIES(!(flags & kAllowEmptyResource), !object.IsEmpty()); CHECK_NOT_NULL(env); if (!env->can_call_into_js()) { @@ -60,7 +61,7 @@ InternalCallbackScope::InternalCallbackScope(Environment* env, // If you hit this assertion, you forgot to enter the v8::Context first. CHECK_EQ(Environment::GetCurrent(env->isolate()), env); - if (asyncContext.async_id != 0) { + if (asyncContext.async_id != 0 && !skip_hooks_) { // No need to check a return value because the application will exit if // an exception occurs. AsyncWrap::EmitBefore(env, asyncContext.async_id); @@ -89,7 +90,7 @@ void InternalCallbackScope::Close() { if (failed_) return; - if (async_context_.async_id != 0) { + if (async_context_.async_id != 0 && !skip_hooks_) { AsyncWrap::EmitAfter(env_, async_context_.async_id); } |