1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-04 19:24:14 +01:00

Bang on tests some more. Ameliorate some async completion issues.

--HG--
extra : rebase_source : 0f550b1650963e4010e447db2df7d6815627bae2
This commit is contained in:
Kris Maglione
2011-02-01 04:02:29 -05:00
parent e38f408b5d
commit a21db1858a
7 changed files with 174 additions and 107 deletions

View File

@@ -1536,10 +1536,19 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
this.yielders--;
}
},
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);
let end = timeout && Date.now() + timeout, result;
let timer = services.Timer(function () {}, 10, services.Timer.TYPE_REPEATING_SLACK);
try {
while (!(result = test.call(self)) && (!end || Date.now() < end))
this.threadYield(false, interruptable);
}
finally {
timer.cancel();
}
return result;
},
yieldable: function yieldable(func)