1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-01 08:02:28 +01:00

Allow plugins onUnload handlers, fix some threadYield issues.

This commit is contained in:
Kris Maglione
2008-12-01 15:08:50 +00:00
parent 855caac185
commit a2550499c8
7 changed files with 24 additions and 15 deletions

View File

@@ -501,7 +501,7 @@ CompletionContext.prototype = {
{
let end = Date.now() + timeout;
while (this.incomplete && (!timeout || Date.now() > end))
liberator.threadYield(true, interruptable);
liberator.threadYield(false, interruptable);
return this.incomplete;
}
}

View File

@@ -566,13 +566,14 @@ function Events() //{{{
if (buffer.loaded == 1)
return true;
var ms = 25000; // maximum time to wait - TODO: add option
var then = new Date().getTime();
for (let now = then; now - then < ms; now = new Date().getTime())
let start = Date.now();
let end = start + 25000; // maximum time to wait - TODO: add option
let now;
while (now = Date.now(), now < end)
{
liberator.threadYield();
if ((now - then) % 1000 < 10)
liberator.dump("waited: " + (now - then) + " ms");
if ((now - start) % 1000 < 10)
liberator.dump("waited: " + (now - start) + " ms");
if (!events.feedingKeys)
return false;

View File

@@ -204,7 +204,7 @@ function Search() //{{{
this.startPt.setStart(node, node.childNodes.length);
this.startPt.setEnd(node, node.childNodes.length);
if (n++ % 20 == 0)
liberator.threadYield();
liberator.threadYield(true);
if (liberator.interrupted)
break;
}

View File

@@ -30,8 +30,13 @@ the terms of any one of the MPL, the GPL or the LGPL.
plugins.contexts = {};
function Script(name)
{
if (plugins.contexts[name])
return plugins.contexts[name];
let self = plugins.contexts[name]
if (self)
{
if (self.onUnload)
self.onUnload();
return self;
}
plugins.contexts[name] = this;
this.NAME = name;
this.__context__ = this;

View File

@@ -1021,7 +1021,10 @@ const liberator = (function () //{{{
if (urls.length > 20 && !force)
{
commandline.input("This will open " + urls.length + " new tabs. Would you like to continue? (yes/[no])",
function (resp) { if (resp && resp.match(/^y(es)?$/i)) liberator.open(urls, where, true); });
function (resp) {
if (resp && resp.match(/^y(es)?$/i))
liberator.open(urls, where, true);
});
return true;
}
@@ -1044,7 +1047,7 @@ const liberator = (function () //{{{
case liberator.NEW_BACKGROUND_TAB:
case liberator.NEW_TAB:
if (!liberator.has("tabs"))
open(urls, liberator.NEW_WINDOW);
return open(urls, liberator.NEW_WINDOW);
let tab = getBrowser().addTab(url, null, null, postdata);
if (where == liberator.NEW_TAB)
@@ -1295,7 +1298,7 @@ const liberator = (function () //{{{
liberator.interrupted = false;
do
{
mainThread.processNextEvent(true);
mainThread.processNextEvent(!flush);
if (liberator.interrupted)
throw new Error("Interrupted");
}

View File

@@ -15,8 +15,8 @@ const template = {
continue;
if (sep && n++)
ret += sep;
//if (interruptable && n % interruptable == 0)
// liberator.threadYield(false, true);
if (interruptable && n % interruptable == 0)
liberator.threadYield(true, true);
ret += val;
}
return ret;

View File

@@ -417,7 +417,7 @@ const util = { //{{{
{
if (Date.now() > endTime)
{
liberator.threadYield(false, true);
liberator.threadYield(true, true);
endTime = Date.now() + time;
}
yield start++;