- Notifications
You must be signed in to change notification settings - Fork 75
worker: implement MessagePort and MessageChannel#98
Uh oh!
There was an error while loading. Please reload this page.
Conversation
src/env.h Outdated
| V(decorated_private_symbol, "node:decorated") \ | ||
| V(npn_buffer_private_symbol, "node:npnBuffer") \ | ||
| V(processed_private_symbol, "node:processed") \ | ||
| V(sab_lifetimepartner_symbol, "node:sharedArrayBufferLiftimePartner") \ |
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.
typo? node:sharedArrayBufferLiftimePartner -> node:sharedArrayBufferLifetimePartner
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.
a) yes, thank you and b) it wasn’t even meant to be in this commit 😄 I’ve fixed it in #58, though
d27a8dc to dd54fc7Comparehybrist commented Oct 9, 2017
References: |
hybrist commented Oct 9, 2017
I assume "along the lines" is mostly referring to the differences in event listener interfaces ( |
TimothyGu left a comment
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.
More review coming.
lib/internal/worker.js Outdated
| } | ||
| Object.defineProperty(MessagePort.prototype,'onmessage',{ | ||
| enumerable: false, |
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.
Make it enumerable 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.
Hm – the idea here was consistency with ES6 class methods, but I guess you’re right, this should match the native ones
src/env.h Outdated
| V(promise_wrap_template, v8::ObjectTemplate) \ | ||
| V(push_values_to_array_function, v8::Function) \ | ||
| V(randombytes_constructor_template, v8::ObjectTemplate) \ | ||
| V(sab_lifetimepartner_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.
Should this be in this commit?
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.
nope :)
| using v8::ValueSerializer; | ||
| namespacenode{ | ||
| namespaceworker{ |
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.
Make it namespace messaging for consistency with the file name?
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.
well … it’s still conceptually part of the worker code, isn’t it?
TimothyGu commented Oct 9, 2017
@jkrems
There's that, and also some additional APIs like |
src/node_messaging.cc Outdated
| // Factor generating the MessagePort JS constructor into its own piece | ||
| // of code, because it is needed early on in the child environment setup. | ||
| Local<FunctionTemplate> templ; | ||
| templ = env->message_port_constructor_template(); |
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.
Merge these two lines?
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 :)
Qard left a comment
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.
Other than one question, it all LGTM.
| this.ref(); | ||
| this.start(); | ||
| } | ||
| }); |
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.
Changing onmessage will stop the message and flaggedMessage events from being emitted. Is that intended behaviour?
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.
Yeah, I would say so. This is only there to match the Web spec more closely, but in that case you don’t want the EventEmitter interface anyways I guess.
hybrist commented Oct 10, 2017
@TimothyGu For context - I was trying to figure out how hard it would be to write portable code against this, so I wasn't worried too much about additional properties and more about meaningful API overlap. I assume the absence of |
addaleax commented Oct 10, 2017
@jkrems Hm, yes. We could add missing methods to the |
hybrist commented Oct 10, 2017
I'm somewhat partial towards "make it a clean superset of the existing/spec browser API" but I'm not sure how realistic that is (and how much value it would provide in practice). Adding |
addaleax commented Oct 10, 2017
@jkrems Do you want to try & take a stab at this yourself? The trickiest thing I guess would be the interaction of all 3 event emitter systems ( |
Implement `MessagePort` and `MessageChannel` along the lines of the DOM classes of the same names. `MessagePort`s initially support transferring only `ArrayBuffer`s.
de35803 to c1d07d1Comparec1d07d1 to 582b756CompareQard commented Oct 15, 2017
The missing bits could probably also just be added later. |
addaleax commented Oct 15, 2017
Landed in f65bb3d |
Implement `MessagePort` and `MessageChannel` along the lines of the DOM classes of the same names. `MessagePort`s initially support transferring only `ArrayBuffer`s. PR-URL: #98 Reviewed-By: Stephen Belanger <[email protected]>
Implement `MessagePort` and `MessageChannel` along the lines of the DOM classes of the same names. `MessagePort`s initially support transferring only `ArrayBuffer`s. Thanks to Stephen Belanger for reviewing this change in its original form, to Benjamin Gruenbaum for reviewing the added tests in their original form, and to Olivia Hugger for reviewing the documentation in its original form. Refs: ayojs/ayo#98
Implement `MessagePort` and `MessageChannel` along the lines of the DOM classes of the same names. `MessagePort`s initially support transferring only `ArrayBuffer`s. Thanks to Stephen Belanger for reviewing this change in its original form, to Benjamin Gruenbaum for reviewing the added tests in their original form, and to Olivia Hugger for reviewing the documentation in its original form. Refs: ayojs/ayo#98
Implement `MessagePort` and `MessageChannel` along the lines of the DOM classes of the same names. `MessagePort`s initially support transferring only `ArrayBuffer`s. Thanks to Stephen Belanger for reviewing this change in its original form, to Benjamin Gruenbaum for reviewing the added tests in their original form, and to Olivia Hugger for reviewing the documentation in its original form. Refs: ayojs/ayo#98
Implement `MessagePort` and `MessageChannel` along the lines of the DOM classes of the same names. `MessagePort`s initially support transferring only `ArrayBuffer`s. Thanks to Stephen Belanger for reviewing this change in its original form, to Benjamin Gruenbaum for reviewing the added tests in their original form, and to Olivia Hugger for reviewing the documentation in its original form. Refs: ayojs/ayo#98
Implement `MessagePort` and `MessageChannel` along the lines of the DOM classes of the same names. `MessagePort`s initially support transferring only `ArrayBuffer`s. Thanks to Stephen Belanger for reviewing this change in its original form, to Benjamin Gruenbaum for reviewing the added tests in their original form, and to Olivia Hugger for reviewing the documentation in its original form. Refs: ayojs/ayo#98 PR-URL: #20876 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Shingo Inoue <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Gus Caplan <[email protected]>
Implement `MessagePort` and `MessageChannel` along the lines of the DOM classes of the same names. `MessagePort`s initially support transferring only `ArrayBuffer`s. Thanks to Stephen Belanger for reviewing this change in its original form, to Benjamin Gruenbaum for reviewing the added tests in their original form, and to Olivia Hugger for reviewing the documentation in its original form. Refs: ayojs/ayo#98 PR-URL: #20876 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Shingo Inoue <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Gus Caplan <[email protected]>
Implement `MessagePort` and `MessageChannel` along the lines of the DOM classes of the same names. `MessagePort`s initially support transferring only `ArrayBuffer`s. Thanks to Stephen Belanger for reviewing this change in its original form, to Benjamin Gruenbaum for reviewing the added tests in their original form, and to Olivia Hugger for reviewing the documentation in its original form. Refs: ayojs/ayo#98 PR-URL: #20876 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Shingo Inoue <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Gus Caplan <[email protected]>
Implement
MessagePortandMessageChannelalong the lines ofthe DOM classes of the same names.
MessagePorts initiallysupport transferring only
ArrayBuffers.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
worker