Use BroadcastChannel to support sub workers#25
Use BroadcastChannel to support sub workers#25rchiodo wants to merge 9 commits intomicrosoft:mainfrom
Conversation
| } | ||
|
|
||
| dispose() { | ||
| this.channel.removeEventListener('message', this._handleMessageEvent.bind(this)); |
There was a problem hiding this comment.
Not happy with requiring a dispose, but since Broadcast channels are global, they need to be cleaned up (don't go away on Worker shutdown)
An alternative would be to force a new channel name on each Client/Server pair, but that would be hard to reconcile because the Client is created in the worker and doesn't have access to the memory of the Server.
Additionally, the BroadcastChannel only works on the same origin. Would the same origin be used for the extension host as the workers in vscode.dev?
|
Okay maybe this isn't going to work in the browser. Seems that SharedArrayBuffers can't be passed over BroadcastChannels. They only work over MessagePorts. Perhaps a BroadcastChannel can be used to send a message port to the main thread somehow. Then the MessagePort can be used to send messages the way the code used to work |
Fixes #23
Switch to using a BroadcastChannel to allow sub workers to participate in sync messages too.