Backed out changeset 135c1e44a92b (bug 1404946)

This commit is contained in:
Sebastian Hengst 2017-10-09 16:23:10 +02:00
parent c9b41f4cb7
commit b668981dca

View File

@ -39,24 +39,20 @@ const {TYPE_ONE_SHOT, TYPE_REPEATING_SLACK} = Ci.nsITimer;
/**
* Runs a promise-like function off the main thread until it is resolved
* through <code>resolve</code> or <code>rejected</code> callbacks.
* The function is guaranteed to be run at least once, irregardless of
* the timeout.
* through |resolve| or |rejected| callbacks. The function is guaranteed
* to be run at least once, irregardless of the timeout.
*
* The <var>func</var> is evaluated every <var>interval</var> for as
* long as its runtime duration does not exceed <var>interval</var>.
* Evaluations occur sequentially, meaning that evaluations of
* <var>func</var> are queued if the runtime evaluation duration of
* <var>func</var> is greater than <var>interval</var>.
* The |func| is evaluated every |interval| for as long as its runtime
* duration does not exceed |interval|. Evaluations occur sequentially,
* meaning that evaluations of |func| are queued if the runtime evaluation
* duration of |func| is greater than |interval|.
*
* <var>func</var> is given two arguments, <code>resolve</code> and
* <code>reject</code>, of which one must be called for the evaluation
* to complete. Calling <code>resolve</code> with an argument
* indicates that the expected wait condition was met and will return
* the passed value to the caller. Conversely, calling
* <code>reject</code> will evaluate <var>func</var> again until
* the <var>timeout</var> duration has elapsed or <var>func</var>
* throws. The passed value to <code>reject</code> will also be
* |func| is given two arguments, |resolve| and |reject|, of which one
* must be called for the evaluation to complete. Calling |resolve| with
* an argument indicates that the expected wait condition was met and
* will return the passed value to the caller. Conversely, calling
* |reject| will evaluate |func| again until the |timeout| duration has
* elapsed or |func| throws. The passed value to |reject| will also be
* returned to the caller once the wait has expired.
*
* Usage:
@ -74,20 +70,20 @@ const {TYPE_ONE_SHOT, TYPE_REPEATING_SLACK} = Ci.nsITimer;
*
* @param {Condition} func
* Function to run off the main thread.
* @param {number=} [timeout=2000] timeout
* Desired timeout. If 0 or less than the runtime evaluation
* time of <var>func</var>, <var>func</var> is guaranteed to run
* at least once. The default is 2000 milliseconds.
* @param {number=} [interval=10] interval
* Duration between each poll of <var>func</var> in milliseconds.
* Defaults to 10 milliseconds.
* @param {number=} timeout
* Desired timeout. If 0 or less than the runtime evaluation time
* of |func|, |func| is guaranteed to run at least once. The default
* is 2000 milliseconds.
* @param {number=} interval
* Duration between each poll of |func| in milliseconds. Defaults to
* 10 milliseconds.
*
* @return {Promise.<*>}
* Yields the value passed to <var>func</var>'s
* <code>resolve</code> or <code>reject</code> callbacks.
* Yields the value passed to |func|'s |resolve| or |reject|
* callbacks.
*
* @throws {*}
* If <var>func</var> throws, its error is propagated.
* If |func| throws, its error is propagated.
*/
wait.until = function(func, timeout = 2000, interval = 10) {
const timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);