Skip to content

Commit e578268

Browse files
addaleaxMylesBorins
authored andcommitted
src: add InternalCallbackScope util constructor
Add an utility constructor for `AsyncWrap` classes that wish to leverage `InternalCallbackScope`s. PR-URL: #16461 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
1 parent 5390d7e commit e578268

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/node.cc

+6
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,12 @@ CallbackScope::~CallbackScope() {
13811381
delete private_;
13821382
}
13831383

1384+
InternalCallbackScope::InternalCallbackScope(AsyncWrap* async_wrap)
1385+
: InternalCallbackScope(async_wrap->env(),
1386+
async_wrap->object(),
1387+
{ async_wrap->get_async_id(),
1388+
async_wrap->get_trigger_async_id() }) {}
1389+
13841390
InternalCallbackScope::InternalCallbackScope(Environment* env,
13851391
Local<Object> object,
13861392
const async_context& asyncContext,

src/node_internals.h

+2
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ class InternalCallbackScope {
282282
v8::Local<v8::Object> object,
283283
const async_context& asyncContext,
284284
ResourceExpectation expect = kRequireResource);
285+
// Utility that can be used by AsyncWrap classes.
286+
explicit InternalCallbackScope(AsyncWrap* async_wrap);
285287
~InternalCallbackScope();
286288
void Close();
287289

0 commit comments

Comments
 (0)