diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-11-03 13:28:34 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-11-06 13:57:57 +0100 |
commit | 4aca277f16b8649b5fc21d41f340fad0a47c2e61 (patch) | |
tree | d7bc9d32f1065cd8200b841d5f6d27320514edf5 /src/api | |
parent | d80e49d6801501a0f2b93c442d5e425ed6fc73fb (diff) | |
download | android-node-v8-4aca277f16b8649b5fc21d41f340fad0a47c2e61.tar.gz android-node-v8-4aca277f16b8649b5fc21d41f340fad0a47c2e61.tar.bz2 android-node-v8-4aca277f16b8649b5fc21d41f340fad0a47c2e61.zip |
src: remove AsyncScope and AsyncCallbackScope
Reduce the number of different scopes we use for async callbacks.
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 | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/api/callback.cc b/src/api/callback.cc index bced9bb7ab..238bf49a54 100644 --- a/src/api/callback.cc +++ b/src/api/callback.cc @@ -34,11 +34,12 @@ CallbackScope::~CallbackScope() { delete private_; } -InternalCallbackScope::InternalCallbackScope(AsyncWrap* async_wrap) +InternalCallbackScope::InternalCallbackScope(AsyncWrap* async_wrap, int flags) : InternalCallbackScope(async_wrap->env(), async_wrap->object(), { async_wrap->get_async_id(), - async_wrap->get_trigger_async_id() }) {} + async_wrap->get_trigger_async_id() }, + flags) {} InternalCallbackScope::InternalCallbackScope(Environment* env, Local<Object> object, @@ -47,10 +48,11 @@ InternalCallbackScope::InternalCallbackScope(Environment* env, : env_(env), async_context_(asyncContext), object_(object), - callback_scope_(env), - skip_hooks_(flags & kSkipAsyncHooks) { + skip_hooks_(flags & kSkipAsyncHooks), + skip_task_queues_(flags & kSkipTaskQueues) { CHECK_IMPLIES(!(flags & kAllowEmptyResource), !object.IsEmpty()); CHECK_NOT_NULL(env); + env->PushAsyncCallbackScope(); if (!env->can_call_into_js()) { failed_ = true; @@ -74,6 +76,7 @@ InternalCallbackScope::InternalCallbackScope(Environment* env, InternalCallbackScope::~InternalCallbackScope() { Close(); + env_->PopAsyncCallbackScope(); } void InternalCallbackScope::Close() { @@ -94,7 +97,7 @@ void InternalCallbackScope::Close() { AsyncWrap::EmitAfter(env_, async_context_.async_id); } - if (env_->async_callback_scope_depth() > 1) { + if (env_->async_callback_scope_depth() > 1 || skip_task_queues_) { return; } |