mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 03:29:00 +01:00
use queued sender for ext host communication
This commit is contained in:
@@ -10,6 +10,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { ExtensionHostMain, IInitData, exit } from 'vs/workbench/node/extensionHostMain';
|
||||
import { create as createIPC, IMainProcessExtHostIPC } from 'vs/platform/extensions/common/ipcRemoteCom';
|
||||
import marshalling = require('vs/base/common/marshalling');
|
||||
import { createQueuedSender } from 'vs/base/node/processes';
|
||||
|
||||
interface IRendererConnection {
|
||||
remoteCom: IMainProcessExtHostIPC;
|
||||
@@ -22,6 +23,9 @@ let onTerminate = function () {
|
||||
exit();
|
||||
};
|
||||
|
||||
// Utility to not flood the process.send() with messages if it is busy catching up
|
||||
const queuedSender = createQueuedSender(process);
|
||||
|
||||
function connectToRenderer(): TPromise<IRendererConnection> {
|
||||
return new TPromise<IRendererConnection>((c, e) => {
|
||||
const stats: number[] = [];
|
||||
@@ -32,7 +36,7 @@ function connectToRenderer(): TPromise<IRendererConnection> {
|
||||
let msg = marshalling.parse(raw);
|
||||
|
||||
const remoteCom = createIPC(data => {
|
||||
process.send(data);
|
||||
queuedSender.send(data);
|
||||
stats.push(data.length);
|
||||
});
|
||||
|
||||
@@ -92,13 +96,13 @@ function connectToRenderer(): TPromise<IRendererConnection> {
|
||||
}, 1000);
|
||||
|
||||
// Tell the outside that we are initialized
|
||||
process.send('initialized');
|
||||
queuedSender.send('initialized');
|
||||
|
||||
c({ remoteCom, initData: msg });
|
||||
});
|
||||
|
||||
// Tell the outside that we are ready to receive messages
|
||||
process.send('ready');
|
||||
queuedSender.send('ready');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user