1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-06 08:54: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

@@ -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);
},