From f31b796175cb5206cfd2899ed5379d9ee7c67ec0 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 9f6c8084cfd3c9..33bf5199d63b01 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1373,6 +1373,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 610347364d5eab..5d2f996cc8c1c5 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -303,6 +303,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();