Bug 1276390 - Use blocking polling in worker to handle subprocess IO. r=aswan
MozReview-Commit-ID: KXqgCLnO7dR
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user