Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
src: add Environment overload of EmitAsyncDestroy
This can be necessary for being able to call the function when no
JS Context is on the stack, e.g. during GC.

Refs: #27218
  • Loading branch information
addaleax committed Apr 16, 2019
commit 7947f48584e85ce0e9fcff87628506aeb10b3d29
7 changes: 5 additions & 2 deletions src/api/hooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ async_context EmitAsyncInit(Isolate* isolate,
}

void EmitAsyncDestroy(Isolate* isolate, async_context asyncContext) {
AsyncWrap::EmitDestroy(
Environment::GetCurrent(isolate), asyncContext.async_id);
EmitAsyncDestroy(Environment::GetCurrent(isolate), asyncContext);
}

void EmitAsyncDestroy(Environment* env, async_context asyncContext) {
AsyncWrap::EmitDestroy(env, asyncContext.async_id);
}

} // namespace node
9 changes: 8 additions & 1 deletion src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,9 +685,16 @@ NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate,
v8::Local<v8::String> name,
async_id trigger_async_id = -1);

/* Emit the destroy() callback. */
/* Emit the destroy() callback. The overload taking an `Environment*` argument
* should be used when the Isolate’s current Context is not associated with
* a Node.js Environment, or when there is no current Context, for example
* when calling this function during garbage collection. In that case, the
* `Environment*` value should have been acquired previously, e.g. through
* `GetCurrentEnvironment()`. */
NODE_EXTERN void EmitAsyncDestroy(v8::Isolate* isolate,
async_context asyncContext);
NODE_EXTERN void EmitAsyncDestroy(Environment* env,
async_context asyncContext);

class InternalCallbackScope;

Expand Down