Our implementation of resolve that will only actually resolve if we are
done waiting everywhere.
196995
function done() {
      // We don't care if we were rejected.
      if (rejected === true) {
        return;
      }
      // Decrement the number of async tasks we are waiting on.
      waiting--;
      // If we are finished waiting then we want to resolve our promise.
      if (waiting <= 0) {
        if (waiting === 0) {
          _resolve(filePaths);
        } else {
          reject(new Error(`Expected a positive number: ${waiting}`));
        }
      }
    }
694299
function () {
    var self = this;
    var future = new Future;
    self.onAllCommitted(function () {
      future['return']();
    });
    self.arm();
    future.wait();
  }
432538
function waitResolveable() {
    var ms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;

    var ret = {};
    ret.promise = new Promise(function (res) {
        ret.resolve = function (x) {
            return res(x);
        };
        setTimeout(res, ms);
    });
    return ret;
}
15625
function eventuallyRejectedWith(promise, expected, done) {
    all([
        promise.should.be.rejectedWith(expected)
    ], done);
}
1148945
function doResolve(promise, resolve, reject, value, context) {
  var _reject = reject;
  var then;
  var _resolve;
  try {
    if (value === promise) {
      throw new TypeError('Cannot fulfill promise with itself');
    }
    var isObj = isObject(value);
    if (isObj && value instanceof promise.constructor) {
      adopt(promise, value._state, value._value, value);
    } else if (isObj && (then = value.then) && isFunction(then)) {
      _resolve = function(value) {
        _resolve = _reject = noop;
        doResolve(promise, resolve, reject, value, value);
      };
      _reject = function(reason) {
        _resolve = _reject = noop;
        reject(reason);
      };
      then.call(
        context,
        function(value) { _resolve(value); },
        function(reason) { _reject(reason); }
      );
    } else {
      resolve(value);
    }
  } catch (e) {
    _reject(e);
  }
}
991498
function resolve(promise, x) {
  /*  sanity check arguments  */

  /*  [Promises/A+ 2.3.1]  */
  if (promise === x || promise.proxy === x) {
    promise.reject(new TypeError('cannot resolve promise with itself'));
    return;
  }
  /*  surgically check for a "then" method
    (mainly to just call the "getter" of "then" only once)  */


  var then;

  if (_typeof(x) === 'object' && x !== null || typeof x === 'function') {
    try {
      then = x.then;
    }
    /*  [Promises/A+ 2.3.3.1, 3.5]  */
    catch (e) {
      promise.reject(e);
      /*  [Promises/A+ 2.3.3.2]  */

      return;
    }
  }
  /*  handle own Thenables    [Promises/A+ 2.3.2]
    and similar "thenables" [Promises/A+ 2.3.3]  */


  if (typeof then === 'function') {
    var resolved = false;

    try {
      /*  call retrieved "then" method */

      /*  [Promises/A+ 2.3.3.3]  */
      then.call(x,
      /*  resolvePromise  */

      /*  [Promises/A+ 2.3.3.3.1]  */
      function (y) {
        if (resolved) return;
        resolved = true;
        /*  [Promises/A+ 2.3.3.3.3]  */

        if (y === x)
          /*  [Promises/A+ 3.6]  */
          promise.reject(new TypeError('circular thenable chain'));else resolve(promise, y);
      },
      /*  rejectPromise  */

      /*  [Promises/A+ 2.3.3.3.2]  */
      function (r) {
        if (resolved) return;
        resolved = true;
        /*  [Promises/A+ 2.3.3.3.3]  */

        promise.reject(r);
      });
    } catch (e) {
      if (!resolved)
        /*  [Promises/A+ 2.3.3.3.3]  */
        promise.reject(e);
      /*  [Promises/A+ 2.3.3.3.4]  */
    }

    return;
  }
  /*  handle other values  */


  promise.fulfill(x);
  /*  [Promises/A+ 2.3.4, 2.3.3.4]  */
}
877508
function resolver (remainingTry, interval) {
      var result = Q.fcall(action);
      if (remainingTry <= 0) {
        return result;
      }
      // In case of failure, wait the interval, retry the action
      return result.fail(function (e) {
        return Q.delay(interval).then(function () {
          return resolver(remainingTry-1, interval*options.intervalMultiplicator);
        });
      });
    }
999738
function attemptNext() {
          if (--settings.attempts > 0 && dirty) {
            dirty = false; // Mark sweep as clean - will get dirty if resolver sees a function return

            resolver(base, []).then(attemptNext);
          } else {
            resolve();
          }
        }
899707
public void onResolve(ResolutionCallback callback) {
    checkState(this.resolveCallback == null, "callback has already been set.");
    checkState(this.value == null, "value is resolved.");
    this.resolveCallback = checkNotNull(callback);
  }
412549
private Set<Location> waitForTasksCompleted() {
        try {
            Set<Location> targets = new HashSet<>();
            FutureTask<Set<Location>> task;
            while ((task = tasks.poll()) != null) {
                // wait for completion
                if (!task.isDone())
                    targets.addAll(task.get());
            }
            return targets;
        } catch (InterruptedException|ExecutionException e) {
            throw new Error(e);
        }
    }
496923
async def resolve(self, client):
        """"""
        if self.resolved:
            return

        if not self._resolve_lock:
            self._resolve_lock = asyncio.Lock(loop=client.loop)

        async with self._resolve_lock:
            if not self.resolved:
                await self._resolve(client)
                self.resolved = True
670093
function eventuallyEqual(promise, expected, done) {
    all([
        promise.should.be.fulfilled,
        promise.should.eventually.deep.equal(expected)
    ], done);
}
699087
function doResolve(fn, self) {
  var done = false;
  try {
    fn(
      function(value) {
        if (done) { return; }
        done = true;
        resolve(self, value);
      },
      function(reason) {
        if (done) { return; }
        done = true;
        reject(self, reason);
      }
    );
  } catch (ex) {
    if (done) { return; }
    done = true;
    reject(self, ex);
  }
}
1011246
function createSimplePromiseCompletedAction(resolve, reject) {
    return (err, result) => {
        if (err) {
            if (reject) {
                reject(err);
            }
        }
        else {
            if (resolve) {
                resolve(result);
            }
        }
    };
}
93883
function (e, data) {
            var that = this,
                getPromise = function (data) {
                    return $.Deferred().resolveWith(that, [data]).promise();
                };
            data.process = function (resolveFunc, rejectFunc) {
                if (resolveFunc || rejectFunc) {
                    data._processQueue = this._processQueue =
                        (this._processQueue || getPromise(this))
                            .pipe(resolveFunc, rejectFunc);
                }
                return this._processQueue || getPromise(this);
            };
            data.submit = function () {
                if (this.state() !== 'pending') {
                    data.jqXHR = this.jqXHR =
                        (that._trigger('submit', e, this) !== false) &&
                            that._onSend(e, this);
                }
                return this.jqXHR || that._getXHRPromise();
            };
            data.abort = function () {
                if (this.jqXHR) {
                    return this.jqXHR.abort();
                }
                return that._getXHRPromise();
            };
            data.state = function () {
                if (this.jqXHR) {
                    return that._getDeferredState(this.jqXHR);
                }
                if (this._processQueue) {
                    return that._getDeferredState(this._processQueue);
                }
            };
            data.progress = function () {
                return this._progress;
            };
            data.response = function () {
                return this._response;
            };
        }
1105847
def wait_for(*dependencies)
      return nil if @serial
      return nil if dependencies.empty?

      dep_set = dependencies.to_set
      until dep_set & solved == dep_set
        sleep 1
        @solver_thread.join unless @solver_thread.alive?
      end
    end
325484
function resolveFuture(reject, resolve) {
      state = STARTED
      return future.fork( function(error) { state = REJECTED
                                            value = error
                                            invokePending('rejected', error)
                                            return reject(error) }
  
                        , function(data)  { state = RESOLVED
                                            value = data
                                            invokePending('resolved', data)
                                            return resolve(data) })}