Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0865d11

Browse filesBrowse files
ofrobotsMylesBorins
authored andcommitted
async_hooks: clean up comments
With some of the recent work, some of the comments were no longer representative of the code, or were otherwise unclear. This commit fixes some obvious issues I found. Ref: 83e5215 Ref: 0784b04 PR-URL: #18467 Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent da0d776 commit 0865d11
Copy full SHA for 0865d11

File tree

Expand file treeCollapse file tree

2 files changed

+14
-13
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-13
lines changed
Open diff view settings
Collapse file

‎lib/internal/async_hooks.js‎

Copy file name to clipboardExpand all lines: lib/internal/async_hooks.js
+12-11Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,28 @@ const async_wrap = process.binding('async_wrap');
1111
* the various asynchronous states of the application. These are:
1212
* kExecutionAsyncId: The async_id assigned to the resource responsible for the
1313
* current execution stack.
14-
* kTriggerAsyncId: The trigger_async_id of the resource responsible for
15-
* the current execution stack.
14+
* kTriggerAsyncId: The async_id of the resource that caused (or 'triggered')
15+
* the resource corresponding to the current execution stack.
1616
* kAsyncIdCounter: Incremental counter tracking the next assigned async_id.
1717
* kDefaultTriggerAsyncId: Written immediately before a resource's constructor
18-
* that sets the value of the init()'s triggerAsyncId. The order of
19-
* retrieving the triggerAsyncId value is passing directly to the
20-
* constructor -> value set in kDefaultTriggerAsyncId -> executionAsyncId of
21-
* the current resource.
18+
* that sets the value of the init()'s triggerAsyncId. The precedence order
19+
* of retrieving the triggerAsyncId value is:
20+
* 1. the value passed directly to the constructor
21+
* 2. value set in kDefaultTriggerAsyncId
22+
* 3. executionAsyncId of the current resource.
2223
*
23-
* async_ids_fast_stack is a Float64Array that contains part of the async ID
24+
* async_ids_stack is a Float64Array that contains part of the async ID
2425
* stack. Each pushAsyncIds() call adds two doubles to it, and each
2526
* popAsyncIds() call removes two doubles from it.
2627
* It has a fixed size, so if that is exceeded, calls to the native
2728
* side are used instead in pushAsyncIds() and popAsyncIds().
2829
*/
2930
const { async_id_symbol, async_hook_fields, async_id_fields } = async_wrap;
3031
// Store the pair executionAsyncId and triggerAsyncId in a std::stack on
31-
// Environment::AsyncHooks::ids_stack_ tracks the resource responsible for the
32-
// current execution stack. This is unwound as each resource exits. In the case
33-
// of a fatal exception this stack is emptied after calling each hook's after()
34-
// callback.
32+
// Environment::AsyncHooks::async_ids_stack_ tracks the resource responsible for
33+
// the current execution stack. This is unwound as each resource exits. In the
34+
// case of a fatal exception this stack is emptied after calling each hook's
35+
// after() callback.
3536
const { pushAsyncIds: pushAsyncIds_, popAsyncIds: popAsyncIds_ } = async_wrap;
3637
// For performance reasons, only track Promises when a hook is enabled.
3738
const { enablePromiseHook, disablePromiseHook } = async_wrap;
Collapse file

‎src/async_wrap.cc‎

Copy file name to clipboardExpand all lines: src/async_wrap.cc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,12 +532,12 @@ void AsyncWrap::Initialize(Local<Object> target,
532532
// this way to allow JS and C++ to read/write each value as quickly as
533533
// possible. The fields are represented as follows:
534534
//
535-
// kAsyncUid: Maintains the state of the next unique id to be assigned.
535+
// kAsyncIdCounter: Maintains the state of the next unique id to be assigned.
536536
//
537537
// kDefaultTriggerAsyncId: Write the id of the resource responsible for a
538538
// handle's creation just before calling the new handle's constructor.
539539
// After the new handle is constructed kDefaultTriggerAsyncId is set back
540-
// to 0.
540+
// to -1.
541541
FORCE_SET_TARGET_FIELD(target,
542542
"async_id_fields",
543543
env->async_hooks()->async_id_fields().GetJSArray());

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.