Deferred constructor

@constructor
@param {Function} canceller
435148
function (canceller) {
        var self = this;
        this._canceller = canceller;
        this._timeout = null;
        this._timer = null;

        this.handled = false;

        this.waiting = [];
        this.result = undefined;
        this.isError = false;
        this.finished = false;

        //this.currentContextHandler = contextHandler.getHandler && contextHandler.getHandler();
        this.__defineGetter__('promise', this.getPromise);
    }
224100
function defer(fn) { var args
        args = slice.call(arguments, 1)
        return delay.apply(this, [fn, 0].concat(args))
    }
421315
function cancelEvent(ev: ?SyntheticEvent<*>) {
  if (!ev) return;
  ev.preventDefault && ev.preventDefault();
  ev.stopPropagation && ev.stopPropagation();
}
710303
function(location) {
		var deferred = new Deferred();
		this._busyWhile(deferred, messages["Loading..."]);
		this._siteClient.loadSiteConfiguration(location).then(
			function(siteConfig) {
				this._setSiteConfiguration(siteConfig);
				this.setDirty(false);
				deferred.resolve(siteConfig);
			}.bind(this),
			function(error) {
				deferred.reject(error);
			});
		return deferred;
	}
192675
function(reject) {
      let index = _.indexOf(this.deferred, reject);
      if (index >= 0) {
        this.deferred.splice(index, 1);
      }
    }
839385
function AsyncComponent(options, loader) {
    this.options = options;
    this.loader = loader;
    this.id = guid++;
    this.children = [];

    // #[begin] reverse
    var reverseWalker = options.reverseWalker;
    if (reverseWalker) {
        var PlaceholderComponent = this.loader.placeholder;
        if (PlaceholderComponent) {
            this.children[0] = new PlaceholderComponent(options);
        }

        this._create();
        insertBefore(this.el, reverseWalker.target, reverseWalker.current);

        var me = this;
        this.loader.start(function (ComponentClass) {
            me.onload(ComponentClass);
        });
    }
    options.reverseWalker = null;
    // #[end]
}
356052
function cancel() {
    timeouts.forEach(function (timeout) {
      clearTimeout(timeout);
    });
    Object.keys(callbacks).forEach(function (key) {
      callbacks[key]('cancel');
      delete callbacks[key];
    });
    timeouts = [];
  }
990583
function defer() /*: { promise: Promise, resolve: resolveHandler, reject: rejectHandler }*/ {
    let resolve, reject;
    const promise = new Promise((...args) => [ resolve, reject ] = args);
    return { promise, resolve, reject };
}
1039836
function buildValidatorFunction(f, fnInfo, negate) {	// this does not matter here
	negate = _.isNil(negate) ? false : negate == true;

	var res = function deferredValidator() {	// this is the Valichain instance
		log('At deferredValidator():', fnInfo);
		var args = arguments;

		var fn = function actualValidator() { // this is the Valichain instance
			log('At actualValidator():', fnInfo, ' / input', this.value);
			if (!this.validating()) return this;	// stop validating

			var result = (fnInfo.context === null) ?
			             f.apply(this.value, args) :	  // works for String's functions
			             f.bind(fnInfo.context, this.value).apply(fnInfo.context, args);
			if (negate) result = !result;

			if (!result) {
				this.fail = fnInfo.newName;
				this.valid = false;
				if (!_.isNil(this.messages)) this.what = this.messages[this.chain.length];
			}
			else {
				this.chain.push(fnInfo.newName);
				this.valid = true;
			}
		};
		fn.info = fnInfo;	// helps debugging

		if (_.isUndefined(this.input)) this.deferred.push(fn);
		else fn.call(this);

		return this;
	};
	res.info = fnInfo;

	return res;
}
841376
function() {
    var d = new Deferred();
    //Necessary to support unbound execution :/
    d.resolve = simpleBind(d, d.resolve);
    d.reject = simpleBind(d, d.reject);
    d.notify = simpleBind(d, d.notify);
    return d;
  }
1164110
function Deferred(clone) {
    var me = this;
    if (me == null || me.constructor != Deferred) {
      return new Deferred(clone);
    }
    me.benchmark = clone;
    clock(me);
  }
331004
function (format, view, data, helpers, callback, nodelist) {
		// if callback has expression prop its actually the nodelist
		if (callback !== undefined && typeof callback.expression === 'string') {
			nodelist = callback;
			callback = undefined;
		}
		
		// If helpers is a `function`, it is actually a callback.
		if (isFunction(helpers)) {
			callback = helpers;
			helpers = undefined;
		}

		// give templates the can namespace:
		helpers = Object.assign({ can: can }, helpers);

		// See if we got passed any deferreds.
		var deferreds = getDeferreds(data);
		var deferred, dataCopy, async, response;
		if (deferreds.length) {
			// Does data contain any deferreds?
			// The deferred that resolves into the rendered content...
			deferred = new Deferred();
			dataCopy = Object.assign({}, data);

			// Add the view request to the list of deferreds.
			deferreds.push(getRenderer(view, true));
			// Wait for the view and all deferreds to finish...
			Deferred.when.apply(can, deferreds)
				.then(function (resolved) {
					// Get all the resolved deferreds.
					var objs = makeArray(arguments),
						// Renderer is the last index of the data.
						renderer = objs.pop(),
						// The result of the template rendering with data.
						result;

					// Make data look like the resolved deferreds.
					if (isDeferred(data)) {
						dataCopy = usefulPart(resolved);
					} else {
						// Go through each prop in data again and
						// replace the defferreds with what they resolved to.
						for (var prop in data) {
							if (isDeferred(data[prop])) {
								dataCopy[prop] = usefulPart(objs.shift());
							}
						}
					}

					// Get the rendered result.
					result = can.view.renderTo(format, renderer, dataCopy, helpers, nodelist);

					// Resolve with the rendered view.
					deferred.resolve(result, dataCopy);

					// If there's a `callback`, call it back with the result.
					if (callback) {
						callback(result, dataCopy);
					}
				}, function () {
					deferred.reject.apply(deferred, arguments);
				});
			// Return the deferred...
			return deferred;
		} else {

			// If there's a `callback` function
			async = isFunction(callback);
			
			// get is called async but in
			// ff will be async so we need to temporarily reset
			deferred = Observation.ignore(getRenderer)(view, async);

			// If we are `async`...
			if (async) {
				// Return the deferred
				response = deferred;
				// And fire callback with the rendered result.
				deferred.then(function (renderer) {
					callback(data ? $view.renderTo(format, renderer, data, helpers, nodelist) : renderer);
				});
			} else {
				// if the deferred is resolved, call the cached renderer instead
				// this is because it's possible, with recursive deferreds to
				// need to render a view while its deferred is _resolving_.  A _resolving_ deferred
				// is a deferred that was just resolved and is calling back it's success callbacks.
				// If a new success handler is called while resoliving, it does not get fired by
				// jQuery's deferred system.  So instead of adding a new callback
				// we use the cached renderer.
				// We also add __view_id on the deferred so we can look up it's cached renderer.
				// In the future, we might simply store either a deferred or the cached result.
				if (deferred.state() === 'resolved' && deferred.__view_id) {
					var currentRenderer = $view.cachedRenderers[deferred.__view_id];
					var result =  data ? $view.renderTo(format, currentRenderer, data, helpers, nodelist) : currentRenderer;
					return result;
				} else {
					// Otherwise, the deferred is complete, so
					// set response to the result of the rendering.
					deferred.then(function (renderer) {
						response = data ? $view.renderTo(format, renderer, data, helpers, nodelist) : renderer;
					});
				}
			}

			return response;
		}
	}
1094799
function (milliseconds) {
            var deferred,
                timer = setTimeout(function () {
                    deferred.emitSuccess();
                }, milliseconds),
                canceller = function () {
                    clearTimeout(timer);
                };
            deferred = new Deferred(canceller);
            return deferred.getPromise();
        }
965782
def _connect_deferred(self, deferred):
        
        self._deferred = deferred

        # Because we use __del__, we need to make sure there are no cycles
        # involving this object, which is why we use a weakref:
        def put(result, eventual=weakref.ref(self)):
            eventual = eventual()
            if eventual:
                eventual._set_result(result)
            else:
                err(result, "Unhandled error in EventualResult")

        deferred.addBoth(put)
1051275
function runHandler(plugin, handler, cancel) {
  return function runHandlerDelegate(data) {
    if (!data) {
      return Promise.resolve();
    }

    return Promise
      .resolve(handler.handler(data, plugin, cancel))
      .then(function(result) {
        return data.configure(result);
      });
  };
}
1079787
function Deferred(clone) {
      var deferred = this;
      if (!(deferred instanceof Deferred)) {
        return new Deferred(clone);
      }
      deferred.benchmark = clone;
      clock(deferred);
    }
205454
function doConstitutors(constructor) {

		var waiting,
		    tasks,
		    i;

		if (has_constituted.get(constructor)) {
			return;
		}

		has_constituted.set(constructor, true);

		tasks = constructor.constitutors;

		if (tasks) {
			for (i = 0; i < tasks.length; i++) {
				doConstructorTask(constructor, tasks[i]);
			}
		}

		waiting = waiting_children.get(constructor);

		if (!waiting || !waiting.length) {
			return;
		}

		for (i = 0; i < waiting.length; i++) {
			doConstitutors(waiting[i]);
		}
	}