mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
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>
This commit is contained in:
1 parent
158d4464d2
commit
0918ea0683
4 files changed
+15
-4
No files matched your search
@@ -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_) {}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1008,6 +1008,9 @@ class NODE_EXTERN CallbackScope {
|
||||
CallbackScope(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> resource,
|
||||
async_context asyncContext);
|
||||
CallbackScope(Environment* env,
|
||||
v8::Local<v8::Object> resource,
|
||||
async_context asyncContext);
|
||||
~CallbackScope();
|
||||
|
||||
void operator=(const CallbackScope&) = delete;
|
||||
|
||||
+1
-1
@@ -539,7 +539,7 @@ class AsyncContext {
|
||||
class CallbackScope : public node::CallbackScope {
|
||||
public:
|
||||
explicit CallbackScope(AsyncContext* async_context)
|
||||
: node::CallbackScope(async_context->node_env()->isolate(),
|
||||
: node::CallbackScope(async_context->node_env(),
|
||||
async_context->resource_.Get(
|
||||
async_context->node_env()->isolate()),
|
||||
async_context->async_context()) {}
|
||||
|
||||
Reference in new issue
Block a user