From 26de09f1a9f6551538027f72030cf2ba22cb94c6 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 24 Oct 2017 23:22:07 +0200 Subject: [PATCH] src: add `InternalCallbackScope` util constructor Add an utility constructor for `AsyncWrap` classes that wish to leverage `InternalCallbackScope`s. PR-URL: https://github.com/nodejs/node/pull/16461 Reviewed-By: Anatoli Papirovski Reviewed-By: James M Snell Reviewed-By: Franziska Hinkelmann --- src/node.cc | 6 ++++++ src/node_internals.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/node.cc b/src/node.cc index 65041362a6..3e8e786c99 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1400,6 +1400,12 @@ CallbackScope::~CallbackScope() { delete private_; } +InternalCallbackScope::InternalCallbackScope(AsyncWrap* async_wrap) + : InternalCallbackScope(async_wrap->env(), + async_wrap->object(), + { async_wrap->get_async_id(), + async_wrap->get_trigger_async_id() }) {} + InternalCallbackScope::InternalCallbackScope(Environment* env, Local object, const async_context& asyncContext, diff --git a/src/node_internals.h b/src/node_internals.h index 258de16ca7..6881cf4ccd 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -307,6 +307,8 @@ class InternalCallbackScope { v8::Local object, const async_context& asyncContext, ResourceExpectation expect = kRequireResource); + // Utility that can be used by AsyncWrap classes. + explicit InternalCallbackScope(AsyncWrap* async_wrap); ~InternalCallbackScope(); void Close();