1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-13 18:25:48 +01:00

Rip out threading code. Fixes issue #119. Fixes issue #128.

This commit is contained in:
Kris Maglione
2010-11-12 00:00:16 -05:00
parent babbde6821
commit 1f8bd6ee81
7 changed files with 11 additions and 94 deletions

View File

@@ -648,7 +648,7 @@ const CommandLine = Module("commandline", {
* commandline.FORCE_MULTILINE - Forces the message to appear in
* the MOW.
*/
echo: requiresMainThread(function echo(str, highlightGroup, flags) {
echo: function echo(str, highlightGroup, flags) {
// dactyl.echo uses different order of flags as it omits the highlight group, change commandline.echo argument order? --mst
if (this._silent)
return;
@@ -694,7 +694,7 @@ const CommandLine = Module("commandline", {
if (action)
action.call(this, str, highlightGroup, single);
}),
},
/**
* Prompt the user. Sets modes.main to COMMAND_LINE, which the user may

View File

@@ -287,7 +287,7 @@ const CompletionContext = Class("CompletionContext", {
if (this._completions)
this.hasItems = this._completions.length > 0;
if (this.updateAsync && !this.noUpdate)
util.callInMainThread(function () { this.onUpdate(); }, this);
this.onUpdate();
},
get createRow() this._createRow || template.completionRow, // XXX
@@ -364,22 +364,6 @@ const CompletionContext = Class("CompletionContext", {
set generate(arg) {
this.hasItems = true;
this._generate = arg;
if (this.background && this.regenerate) {
let lock = {};
this.cache.backgroundLock = lock;
this.incomplete = true;
let thread = this.getCache("backgroundThread", util.newThread);
util.callAsync(thread, this, function () {
if (this.cache.backgroundLock != lock)
return;
let items = this.generate();
if (this.cache.backgroundLock != lock)
return;
this.incomplete = false;
if (items != null)
this.completions = items;
});
}
},
get ignoreCase() {
@@ -395,11 +379,11 @@ const CompletionContext = Class("CompletionContext", {
set ignoreCase(val) this._ignoreCase = val,
get items() {
if (!this.hasItems || this.backgroundLock)
if (!this.hasItems)
return [];
// Regenerate completions if we must
if (this.generate && !this.background) {
if (this.generate) {
// XXX
this.noUpdate = true;
this.completions = this.generate();

View File

@@ -136,7 +136,7 @@ const Dactyl = Module("dactyl", {
* bell may be either audible or visual depending on the value of the
* 'visualbell' option.
*/
beep: requiresMainThread(function () {
beep: function () {
if (options["visualbell"]) {
// flash the visual bell
let panel = document.getElementById("dactyl-deck-bell");
@@ -156,7 +156,7 @@ const Dactyl = Module("dactyl", {
let soundService = Cc["@mozilla.org/sound;1"].getService(Ci.nsISound);
soundService.beep();
}
}),
},
/**
* Reads a string from the system clipboard.

View File

@@ -251,7 +251,7 @@ const Editor = Module("editor", {
dactyl.assert(args.length >= 1, "No editor specified");
args.push(path);
util.callInThread(null, io.run, io.expandPath(args.shift()), args, true);
io.run(io.expandPath(args.shift()), args, true);
},
// TODO: clean up with 2 functions for textboxes and currentEditor?

View File

@@ -263,12 +263,11 @@ lookup:
}
let process = services.create("process");
let isMain = services.get("threading").isMainThread;
process.init(file);
process.run(blocking && !isMain, args.map(String), args.length);
process.run(false, args.map(String), args.length);
try {
if (blocking && isMain)
if (blocking)
while (process.isRunning)
util.threadYield(false, true);
}