-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
src: use JS inheritance for AsyncWrap
#23094
Conversation
For all classes descending from `AsyncWrap`, use JS inheritance instead of manually adding methods to the individual classes. This allows cleanup of some code around transferring handles over IPC.
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.
YES!!!
Left a few comments, but nothing blocking.
src/env.h
Outdated
@@ -319,7 +319,8 @@ struct PackageConfig { | |||
V(async_hooks_destroy_function, v8::Function) \ | |||
V(async_hooks_init_function, v8::Function) \ | |||
V(async_hooks_promise_resolve_function, v8::Function) \ | |||
V(async_wrap_constructor_template, v8::FunctionTemplate) \ | |||
V(async_wrap_object_constructor_template, v8::FunctionTemplate) \ |
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.
Maybe use ctor
for this name as well, for consistency?
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.
Done!
Definitely a good idea, I think, but is this going to be semver-major? |
@jasnell If necessary, I would be okay with that, but could you explain why this is semver-major? It doesn’t touch public API or remove methods, it just moves them to a different position on the prototype chain (of internal objects). |
Largely defensive. It shouldn't be breaking but as we've seen many times, it pays to be careful. At the very least we need a citgm run to be sure |
I ran CITGM – there are a lot of failures because of #23122, but in the diff between the run here and the master run, I didn’t find anything that would point to issues with this PR. |
Hopefully ok then :) |
@jasnell I think this will require a backport PR for v10.x anyway … let’s run CITGM on that as well, that should give a much clearer picture. |
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.
Still LGTM
New CI: https://ci.nodejs.org/job/node-test-pull-request/17517/ (This still needs to wait for a second approval, or two more days.) |
Re-run of node-test-commit-aix. |
Btw, @joyeecheung … just thinking out loud: The most natural way to do mirror the C++ multiple inheritance might be to create a second native JS class (e.g. That sounds semver-major to me, though, and I still have some native stream refactoring that I’d like to do, so maybe I’d keep that approach in mind and we could implement it late in the Node 11 release cycle? |
Isn't that kind of like (Or..maybe we should do it the other way around, why does |
Because it’s both a class that wraps a libuv handle, and is a stream at the same time – it does make sense to use multiple inheritance here… |
… and again, Windows: https://ci.nodejs.org/job/node-test-commit-windows-fanned/21229/ |
Landed in d527dde |
For all classes descending from `AsyncWrap`, use JS inheritance instead of manually adding methods to the individual classes. This allows cleanup of some code around transferring handles over IPC. PR-URL: #23094 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
For all classes descending from `AsyncWrap`, use JS inheritance instead of manually adding methods to the individual classes. This allows cleanup of some code around transferring handles over IPC. PR-URL: nodejs#23094 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
For all classes descending from `AsyncWrap`, use JS inheritance instead of manually adding methods to the individual classes. This allows cleanup of some code around transferring handles over IPC. Backport-PR-URL: #23247 PR-URL: #23094 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
For all classes descending from `AsyncWrap`, use JS inheritance instead of manually adding methods to the individual classes. This allows cleanup of some code around transferring handles over IPC. Backport-PR-URL: #23247 PR-URL: #23094 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
For all classes descending from `AsyncWrap`, use JS inheritance instead of manually adding methods to the individual classes. This allows cleanup of some code around transferring handles over IPC. PR-URL: #23094 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
For all classes descending from
AsyncWrap
, use JS inheritanceinstead of manually adding methods to the individual classes.
This allows cleanup of some code around transferring handles
over IPC.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes