-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
timers: add helper fn for async init #18825
Conversation
There are currently 3 places in Timers where the exact same code appears. Instead create a helper function that does the same job of setting asyncId & triggerAsyncId, as well as calling emitInit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
lib/internal/timers.js
Outdated
@@ -37,6 +38,14 @@ function getTimers() { | |||
return timers; | |||
} | |||
|
|||
function initAsyncResource(resource, type = 'Timeout') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking nit: I personally would remove the default and always pass in the value explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I was undecided on whether to do this or not so adjusted now.
Landed in 28f3ffb |
There are currently 3 places in Timers where the exact same code appears. Instead create a helper function that does the same job of setting asyncId & triggerAsyncId, as well as calling emitInit. PR-URL: #18825 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Should this be backported to |
There are currently 3 places in Timers where the exact same code appears. Instead create a helper function that does the same job of setting asyncId & triggerAsyncId, as well as calling emitInit. PR-URL: nodejs#18825 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
This should likely be included in a larger backport of timers to v8.x |
There are currently 3 places in Timers where this exact same code appears. Instead create a helper function that does the same job.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
timers