Skip to content

Commit f31b796

Browse files
addaleaxcjihrig
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]>
1 parent 224ea15 commit f31b796

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
@@ -1373,6 +1373,12 @@ CallbackScope::~CallbackScope() {
13731373
delete private_;
13741374
}
13751375

1376+
InternalCallbackScope::InternalCallbackScope(AsyncWrap* async_wrap)
1377+
: InternalCallbackScope(async_wrap->env(),
1378+
async_wrap->object(),
1379+
{ async_wrap->get_async_id(),
1380+
async_wrap->get_trigger_async_id() }) {}
1381+
13761382
InternalCallbackScope::InternalCallbackScope(Environment* env,
13771383
Local<Object> object,
13781384
const async_context& asyncContext,

src/node_internals.h

+2
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ class InternalCallbackScope {
303303
v8::Local<v8::Object> object,
304304
const async_context& asyncContext,
305305
ResourceExpectation expect = kRequireResource);
306+
// Utility that can be used by AsyncWrap classes.
307+
explicit InternalCallbackScope(AsyncWrap* async_wrap);
306308
~InternalCallbackScope();
307309
void Close();
308310

0 commit comments

Comments
 (0)