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

Add timeout arg to util.waitFor.

--HG--
branch : key-processing
This commit is contained in:
Kris Maglione
2011-01-27 22:14:03 -05:00
parent 7f15781e41
commit abb434ce7c
3 changed files with 5 additions and 6 deletions

View File

@@ -916,7 +916,7 @@ var Events = Module("events", {
let start = Date.now();
let end = start + (maxWaitTime * 1000);
util.waitFor(function () !events.feedingKeys || buffer.loaded || Date.now() > end);
util.waitFor(function () !events.feedingKeys || buffer.loaded, this, maxWaitTime);
commandline.clear();
if (!buffer.loaded)

View File

@@ -804,9 +804,7 @@ var CompletionContext = Class("CompletionContext", {
* If 0 or null, wait indefinitely.
*/
wait: function wait(interruptable, timeout) {
let end = Date.now() + timeout;
util.waitFor(function () !this.incomplete || (this.timeout && Date.now() > end),
this);
util.waitFor(function () !this.incomplete, this, timeout);
return this.incomplete;
}
}, {

View File

@@ -1526,8 +1526,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
this.yielders--;
}
},
waitFor: function waitFor(test, self, interruptable) {
while (!test.call(self))
waitFor: function waitFor(test, self, timeout, interruptable) {
let end = timeout && Date.now() + timeout;
while ((!end || Date.now() < end) && !test.call(self))
this.threadYield(false, interruptable);
},