mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 23:56:58 +00:00

Adds a variant of AsyncHooksGetExecutionAsyncId that takes a V8 Context and returns the async ID belonging to the Environment (if any) of that Context. Sometimes we want to use Isolate::GetEnteredOrMicrotaskContext insteads of Isolate::GetCurrentContext (e.g. recording the async ID in a V8 GC prologue callback) when current context is not set. PR-URL: https://github.com/nodejs/node/pull/57820 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
36 lines
1017 B
C++
36 lines
1017 B
C++
#include "node.h"
|
|
|
|
namespace {
|
|
|
|
using v8::FunctionCallbackInfo;
|
|
using v8::Local;
|
|
using v8::Object;
|
|
using v8::Value;
|
|
|
|
void GetExecutionAsyncId(const FunctionCallbackInfo<Value>& args) {
|
|
args.GetReturnValue().Set(
|
|
node::AsyncHooksGetExecutionAsyncId(args.GetIsolate()));
|
|
}
|
|
|
|
void GetExecutionAsyncIdWithContext(const FunctionCallbackInfo<Value>& args) {
|
|
args.GetReturnValue().Set(node::AsyncHooksGetExecutionAsyncId(
|
|
args.GetIsolate()->GetCurrentContext()));
|
|
}
|
|
|
|
void GetTriggerAsyncId(const FunctionCallbackInfo<Value>& args) {
|
|
args.GetReturnValue().Set(
|
|
node::AsyncHooksGetTriggerAsyncId(args.GetIsolate()));
|
|
}
|
|
|
|
void Initialize(Local<Object> exports) {
|
|
NODE_SET_METHOD(exports, "getExecutionAsyncId", GetExecutionAsyncId);
|
|
NODE_SET_METHOD(exports,
|
|
"getExecutionAsyncIdWithContext",
|
|
GetExecutionAsyncIdWithContext);
|
|
NODE_SET_METHOD(exports, "getTriggerAsyncId", GetTriggerAsyncId);
|
|
}
|
|
|
|
} // anonymous namespace
|
|
|
|
NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)
|