Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Madsen <amwebdk@gmail.com>2017-09-26 16:50:10 +0300
committerAndreas Madsen <amwebdk@gmail.com>2017-09-26 16:50:10 +0300
commit3a69ef55e06cda552e7ad295ddf904e1c70ae13f (patch)
treea33643b534a256e0cefdb0a275b38ee5ee9defcf /lib/async_hooks.js
parentf9e5709ea0bad223d44ade1760917764dca4c0cb (diff)
async_hooks: consistent internal naming
PR-URL: https://github.com/nodejs/node/pull/15569 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/async_hooks.js')
-rw-r--r--lib/async_hooks.js66
1 files changed, 35 insertions, 31 deletions
diff --git a/lib/async_hooks.js b/lib/async_hooks.js
index 37ff5650647..9bb3a993afa 100644
--- a/lib/async_hooks.js
+++ b/lib/async_hooks.js
@@ -6,20 +6,21 @@ const errors = require('internal/errors');
* Environment::AsyncHooks::fields_[]. Each index tracks the number of active
* hooks for each type.
*
- * async_uid_fields is a Float64Array wrapping the double array of
+ * async_id_fields is a Float64Array wrapping the double array of
* Environment::AsyncHooks::uid_fields_[]. Each index contains the ids for the
* various asynchronous states of the application. These are:
- * kCurrentAsyncId: The async_id assigned to the resource responsible for the
+ * kExecutionAsyncId: The async_id assigned to the resource responsible for the
* current execution stack.
- * kCurrentTriggerId: The trigger_async_id of the resource responsible for the
- * current execution stack.
- * kAsyncUidCntr: Incremental counter tracking the next assigned async_id.
- * kInitTriggerId: Written immediately before a resource's constructor that
- * sets the value of the init()'s triggerAsyncId. The order of retrieving
- * the triggerAsyncId value is passing directly to the constructor -> value
- * set in kInitTriggerId -> executionAsyncId of the current resource.
+ * kTriggerAsyncId: The trigger_async_id of the resource responsible for
+ * the current execution stack.
+ * kAsyncIdCounter: Incremental counter tracking the next assigned async_id.
+ * kInitTriggerAsyncId: Written immediately before a resource's constructor
+ * that sets the value of the init()'s triggerAsyncId. The order of
+ * retrieving the triggerAsyncId value is passing directly to the
+ * constructor -> value set in kInitTriggerAsyncId -> executionAsyncId of
+ * the current resource.
*/
-const { async_hook_fields, async_uid_fields } = async_wrap;
+const { async_hook_fields, async_id_fields } = async_wrap;
// Store the pair executionAsyncId and triggerAsyncId in a std::stack on
// Environment::AsyncHooks::ids_stack_ tracks the resource responsible for the
// current execution stack. This is unwound as each resource exits. In the case
@@ -58,14 +59,14 @@ const active_hooks = {
// Each constant tracks how many callbacks there are for any given step of
// async execution. These are tracked so if the user didn't include callbacks
// for a given step, that step can bail out early.
-const { kInit, kBefore, kAfter, kDestroy, kPromiseResolve, kTotals,
- kCurrentAsyncId, kCurrentTriggerId, kAsyncUidCntr,
- kInitTriggerId } = async_wrap.constants;
+const { kInit, kBefore, kAfter, kDestroy, kTotals, kPromiseResolve,
+ kExecutionAsyncId, kTriggerAsyncId, kAsyncIdCounter,
+ kInitTriggerAsyncId } = async_wrap.constants;
// Symbols used to store the respective ids on both AsyncResource instances and
// internal resources. They will also be assigned to arbitrary objects passed
// in by the user that take place of internally constructed objects.
-const { async_id_symbol, trigger_id_symbol } = async_wrap;
+const { async_id_symbol, trigger_async_id_symbol } = async_wrap;
// Used in AsyncHook and AsyncResource.
const init_symbol = Symbol('init');
@@ -234,12 +235,12 @@ function createHook(fns) {
function executionAsyncId() {
- return async_uid_fields[kCurrentAsyncId];
+ return async_id_fields[kExecutionAsyncId];
}
function triggerAsyncId() {
- return async_uid_fields[kCurrentTriggerId];
+ return async_id_fields[kTriggerAsyncId];
}
@@ -258,14 +259,16 @@ class AsyncResource {
triggerAsyncId);
}
- this[async_id_symbol] = ++async_uid_fields[kAsyncUidCntr];
- this[trigger_id_symbol] = triggerAsyncId;
+ this[async_id_symbol] = ++async_id_fields[kAsyncIdCounter];
+ this[trigger_async_id_symbol] = triggerAsyncId;
- emitInitScript(this[async_id_symbol], type, this[trigger_id_symbol], this);
+ emitInitScript(
+ this[async_id_symbol], type, this[trigger_async_id_symbol], this
+ );
}
emitBefore() {
- emitBeforeScript(this[async_id_symbol], this[trigger_id_symbol]);
+ emitBeforeScript(this[async_id_symbol], this[trigger_async_id_symbol]);
return this;
}
@@ -284,7 +287,7 @@ class AsyncResource {
}
triggerAsyncId() {
- return this[trigger_id_symbol];
+ return this[trigger_async_id_symbol];
}
}
@@ -308,7 +311,7 @@ function runInAsyncIdScope(asyncId, cb) {
// counter increment first. Since it's done the same way in
// Environment::new_async_uid()
function newUid() {
- return ++async_uid_fields[kAsyncUidCntr];
+ return ++async_id_fields[kAsyncIdCounter];
}
@@ -316,20 +319,20 @@ function newUid() {
// the user to safeguard this call and make sure it's zero'd out when the
// constructor is complete.
function initTriggerId() {
- var tId = async_uid_fields[kInitTriggerId];
+ var triggerAsyncId = async_id_fields[kInitTriggerAsyncId];
// Reset value after it's been called so the next constructor doesn't
// inherit it by accident.
- async_uid_fields[kInitTriggerId] = 0;
- if (tId <= 0)
- tId = async_uid_fields[kCurrentAsyncId];
- return tId;
+ async_id_fields[kInitTriggerAsyncId] = 0;
+ if (triggerAsyncId <= 0)
+ triggerAsyncId = async_id_fields[kExecutionAsyncId];
+ return triggerAsyncId;
}
function setInitTriggerId(triggerAsyncId) {
// CHECK(Number.isSafeInteger(triggerAsyncId))
// CHECK(triggerAsyncId > 0)
- async_uid_fields[kInitTriggerId] = triggerAsyncId;
+ async_id_fields[kInitTriggerAsyncId] = triggerAsyncId;
}
@@ -346,8 +349,9 @@ function emitInitScript(asyncId, type, triggerAsyncId, resource) {
if (triggerAsyncId === null) {
triggerAsyncId = initTriggerId();
} else {
- // If a triggerAsyncId was passed, any kInitTriggerId still must be null'd.
- async_uid_fields[kInitTriggerId] = 0;
+ // If a triggerAsyncId was passed, any kInitTriggerAsyncId still must be
+ // null'd.
+ async_id_fields[kInitTriggerAsyncId] = 0;
}
if (!Number.isSafeInteger(asyncId) || asyncId < -1) {
@@ -446,7 +450,7 @@ function emitDestroyScript(asyncId) {
// Return early if there are no destroy callbacks, or invalid asyncId.
if (async_hook_fields[kDestroy] === 0 || asyncId <= 0)
return;
- async_wrap.addIdToDestroyList(asyncId);
+ async_wrap.queueDestroyAsyncId(asyncId);
}