| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d4fc282 commit e1d3a9e
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -196,6 +196,12 @@ async_id AsyncHooksGetExecutionAsyncId(Isolate* isolate) { | |||
| 196 | 196 | return env->execution_async_id(); | |
| 197 | 197 | } | |
| 198 | 198 | ||
| 199 | + async_id AsyncHooksGetExecutionAsyncId(Local<Context> context) { | ||
| 200 | + Environment* env = Environment::GetCurrent(context); | ||
| 201 | + if (env == nullptr) return -1; | ||
| 202 | + return env->execution_async_id(); | ||
| 203 | + } | ||
| 204 | + | ||
| 199 | 205 | async_id AsyncHooksGetTriggerAsyncId(Isolate* isolate) { | |
| 200 | 206 | Environment* env = Environment::GetCurrent(isolate); | |
| 201 | 207 | if (env == nullptr) return -1; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1387,6 +1387,12 @@ NODE_EXTERN void RequestInterrupt(Environment* env, | |||
| 1387 | 1387 | * I/O from native code. */ | |
| 1388 | 1388 | NODE_EXTERN async_id AsyncHooksGetExecutionAsyncId(v8::Isolate* isolate); | |
| 1389 | 1389 | ||
| 1390 | + /* Returns the id of the current execution context. If the return value is | ||
| 1391 | + * zero then no execution has been set. This will happen if the user handles | ||
| 1392 | + * I/O from native code. */ | ||
| 1393 | + NODE_EXTERN async_id | ||
| 1394 | + AsyncHooksGetExecutionAsyncId(v8::Local<v8::Context> context); | ||
| 1395 | + | ||
| 1390 | 1396 | /* Return same value as async_hooks.triggerAsyncId(); */ | |
| 1391 | 1397 | NODE_EXTERN async_id AsyncHooksGetTriggerAsyncId(v8::Isolate* isolate); | |
| 1392 | 1398 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,13 +12,21 @@ void GetExecutionAsyncId(const FunctionCallbackInfo<Value>& args) { | |||
| 12 | 12 | node::AsyncHooksGetExecutionAsyncId(args.GetIsolate())); | |
| 13 | 13 | } | |
| 14 | 14 | ||
| 15 | + void GetExecutionAsyncIdWithContext(const FunctionCallbackInfo<Value>& args) { | ||
| 16 | + args.GetReturnValue().Set(node::AsyncHooksGetExecutionAsyncId( | ||
| 17 | + args.GetIsolate()->GetCurrentContext())); | ||
| 18 | + } | ||
| 19 | + | ||
| 15 | 20 | void GetTriggerAsyncId(const FunctionCallbackInfo<Value>& args) { | |
| 16 | 21 | args.GetReturnValue().Set( | |
| 17 | 22 | node::AsyncHooksGetTriggerAsyncId(args.GetIsolate())); | |
| 18 | 23 | } | |
| 19 | 24 | ||
| 20 | 25 | void Initialize(Local<Object> exports) { | |
| 21 | 26 | NODE_SET_METHOD(exports, "getExecutionAsyncId", GetExecutionAsyncId); | |
| 27 | + NODE_SET_METHOD(exports, | ||
| 28 | + "getExecutionAsyncIdWithContext", | ||
| 29 | + GetExecutionAsyncIdWithContext); | ||
| 22 | 30 | NODE_SET_METHOD(exports, "getTriggerAsyncId", GetTriggerAsyncId); | |
| 23 | 31 | } | |
| 24 | 32 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,10 @@ assert.strictEqual( | |||
| 9 | 9 | binding.getExecutionAsyncId(), | |
| 10 | 10 | async_hooks.executionAsyncId(), | |
| 11 | 11 | ); | |
| 12 | + assert.strictEqual( | ||
| 13 | + binding.getExecutionAsyncIdWithContext(), | ||
| 14 | + async_hooks.executionAsyncId(), | ||
| 15 | + ); | ||
| 12 | 16 | assert.strictEqual( | |
| 13 | 17 | binding.getTriggerAsyncId(), | |
| 14 | 18 | async_hooks.triggerAsyncId(), | |
@@ -19,6 +23,10 @@ process.nextTick(common.mustCall(() => { | |||
| 19 | 23 | binding.getExecutionAsyncId(), | |
| 20 | 24 | async_hooks.executionAsyncId(), | |
| 21 | 25 | ); | |
| 26 | + assert.strictEqual( | ||
| 27 | + binding.getExecutionAsyncIdWithContext(), | ||
| 28 | + async_hooks.executionAsyncId(), | ||
| 29 | + ); | ||
| 22 | 30 | assert.strictEqual( | |
| 23 | 31 | binding.getTriggerAsyncId(), | |
| 24 | 32 | async_hooks.triggerAsyncId(), | |
| Back | FazBrowse Home | New Git URL |
0 commit comments