-
-
Notifications
You must be signed in to change notification settings - Fork 35k
Closed
Labels
async_hooksIssues and PRs related to the async hooks subsystem.Issues and PRs related to the async hooks subsystem.questionIssues that look for answers.Issues that look for answers.
Description
Basically looking for an event loop tick id, for this purpose:
const run = (cb) => {
let isCurrentTick = true;
process.nextTick(() => {
isCurrentTick = false;
});
doSomeWork(() =>{
isCurrentTIck ? process.nextTick(cb) : cb();
});
}this is an optimization that can reduce the memory overhead of servers. It's mostly about convenience, but in some cases very necessary when you don't know for sure if something is being fired asynchronously or not.
so the fix looks like:
const run = (cb) => {
const currentEventLoopId = process.getEventTickId();
doSomeWork(() =>{
currentEventLoopId === process.getEventTickId() ? process.nextTick(cb) : cb();
});
}so what I am looking for is an incrementing id for every tick of the event loop. This fix would obviate the need for using process.nexTick calls to store some local boolean variable as in the first code example.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
async_hooksIssues and PRs related to the async hooks subsystem.Issues and PRs related to the async hooks subsystem.questionIssues that look for answers.Issues that look for answers.