GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — process: use a class for nextTick resources · nodejs/node@8c39411

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/process
    • task_queues.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/process/task_queues.js‎

Copy file name to clipboardExpand all lines: lib/internal/process/task_queues.js
+14-7Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ function processTicksAndRejections() {
110110

111111
// `nextTick()` will not enqueue any callback when the process is about to
112112
// exit since the callback would not have a chance to be executed.
113+
// The async resource behind each `process.nextTick()` call. A class keeps
114+
// every instance on one map with all fields in-object; an object literal
115+
// with computed symbol keys spills them into a separate property array.
116+
class TickObject {
117+
constructor(callback, args, asyncId, triggerAsyncId) {
118+
this[async_id_symbol] = asyncId;
119+
this[trigger_async_id_symbol] = triggerAsyncId;
120+
this[async_context_frame] = AsyncContextFrame.current();
121+
this.callback = callback;
122+
this.args = args;
123+
}
124+
}
125+
113126
function nextTick(callback) {
114127
validateFunction(callback, 'callback');
115128

@@ -132,13 +145,7 @@ function nextTick(callback) {
132145
setHasTickScheduled(true);
133146
const asyncId = newAsyncId();
134147
const triggerAsyncId = getDefaultTriggerAsyncId();
135-
const tickObject = {
136-
[async_id_symbol]: asyncId,
137-
[trigger_async_id_symbol]: triggerAsyncId,
138-
[async_context_frame]: AsyncContextFrame.current(),
139-
callback,
140-
args,
141-
};
148+
const tickObject = new TickObject(callback, args, asyncId, triggerAsyncId);
142149
if (initHooksExist())
143150
emitInit(asyncId, 'TickObject', triggerAsyncId, tickObject);
144151
queue.push(tickObject);

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.