Bug 1276390 - Use blocking polling in worker to handle subprocess IO. r=aswan

MozReview-Commit-ID: KXqgCLnO7dR
This commit is contained in:
Kris Maglione
2016-07-28 16:27:25 -07:00
parent 9edbeb583e
commit bf1d63376b
9 changed files with 301 additions and 28 deletions

View File

@@ -9,7 +9,7 @@
/* exported SubprocessImpl */
/* globals BaseProcess */
/* globals BaseProcess, PromiseWorker */
var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
@@ -24,10 +24,35 @@ Cu.import("resource://gre/modules/subprocess/subprocess_common.jsm");
Services.scriptloader.loadSubScript("resource://gre/modules/subprocess/subprocess_shared.js", this);
Services.scriptloader.loadSubScript("resource://gre/modules/subprocess/subprocess_shared_win.js", this);
class WinPromiseWorker extends PromiseWorker {
constructor(...args) {
super(...args);
this.signalEvent = libc.CreateSemaphoreW(null, 0, 32, null);
this.call("init", [{
signalEvent: String(ctypes.cast(this.signalEvent, ctypes.uintptr_t).value),
}]);
}
signalWorker() {
libc.ReleaseSemaphore(this.signalEvent, 1, null);
}
postMessage(...args) {
this.signalWorker();
return super.postMessage(...args);
}
}
class Process extends BaseProcess {
static get WORKER_URL() {
return "resource://gre/modules/subprocess/subprocess_worker_win.js";
}
static get WorkerClass() {
return WinPromiseWorker;
}
}
var SubprocessWin = {
@@ -37,7 +62,6 @@ var SubprocessWin = {
return Process.create(options);
},
* getEnvironment() {
let env = libc.GetEnvironmentStringsW();
try {