mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-09 15:35:45 +01:00
Add timeout arg to util.waitFor.
--HG-- branch : key-processing
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}, {
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user