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
path: root/src/api
diff options
context:
space:
mode:
authorDarshan Sen <darshan.sen@postman.com>2021-08-15 08:30:35 +0300
committerNode.js GitHub Bot <github-bot@iojs.org>2021-08-21 09:53:50 +0300
commit16853c9d551275dce5390e10a1f1704e9954430b (patch)
tree657deb67cebb11132449f78999bf2ce844fe9e78 /src/api
parent248f4c376444d0202f1d08f039c59485d6aea2e9 (diff)
src: add a constructor overload for CallbackScope
This overload accepts the current Environment* as an argument, unlike the other constructor, which accepts an Isolate*. This is useful because we can pass the current Environment* directly instead of recomputing it from the Isolate* inside the constructor. Signed-off-by: Darshan Sen <darshan.sen@postman.com> PR-URL: https://github.com/nodejs/node/pull/39768 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Diffstat (limited to 'src/api')
-rw-r--r--src/api/async_resource.cc4
-rw-r--r--src/api/callback.cc10
2 files changed, 11 insertions, 3 deletions
diff --git a/src/api/async_resource.cc b/src/api/async_resource.cc
index 0a2437fe6ed..3c4fbdadbc4 100644
--- a/src/api/async_resource.cc
+++ b/src/api/async_resource.cc
@@ -62,10 +62,8 @@ async_id AsyncResource::get_trigger_async_id() const {
return async_context_.trigger_async_id;
}
-// TODO(addaleax): We shouldn’t need to use env_->isolate() if we’re just going
-// to end up using the Isolate* to figure out the Environment* again.
AsyncResource::CallbackScope::CallbackScope(AsyncResource* res)
- : node::CallbackScope(res->env_->isolate(),
+ : node::CallbackScope(res->env_,
res->resource_.Get(res->env_->isolate()),
res->async_context_) {}
diff --git a/src/api/callback.cc b/src/api/callback.cc
index 911b1160eba..8f9d617d1ea 100644
--- a/src/api/callback.cc
+++ b/src/api/callback.cc
@@ -26,6 +26,16 @@ CallbackScope::CallbackScope(Isolate* isolate,
try_catch_.SetVerbose(true);
}
+CallbackScope::CallbackScope(Environment* env,
+ Local<Object> object,
+ async_context asyncContext)
+ : private_(new InternalCallbackScope(env,
+ object,
+ asyncContext)),
+ try_catch_(env->isolate()) {
+ try_catch_.SetVerbose(true);
+}
+
CallbackScope::~CallbackScope() {
if (try_catch_.HasCaught())
private_->MarkAsFailed();