Forks something into another process and returns a deferred object.
540974
public function fork($callable)
    {
        if (!is_callable($callable)) {
            throw new UnexpectedTypeException($callable, 'callable');
        }

        // allow the system to cleanup before forking
        $this->dispatcher->dispatch(Events::PRE_FORK);

        if (-1 === $pid = pcntl_fork()) {
            throw new ProcessControlException('Unable to fork a new process');
        }

        if (0 === $pid) {
            // reset the list of child processes
            $this->forks = array();

            // setup the shared memory
            $shm = $this->factory->createSharedMemory(null, $this->signal);
            $message = new ExitMessage();

            // phone home on shutdown
            register_shutdown_function(function() use($shm, $message) {
                $status = null;

                try {
                    $shm->send($message, false);
                } catch (\Exception $e) {
                    // probably an error serializing the result
                    $message->setResult(null);
                    $message->setError(Error::fromException($e));

                    $shm->send($message, false);

                    exit(2);
                }
            });

            // dispatch an event so the system knows it's in a new process
            $this->dispatcher->dispatch(Events::POST_FORK);

            if (!$this->debug) {
                ob_start();
            }

            try {
                $result = call_user_func($callable, $shm);

                $message->setResult($result);
                $status = is_integer($result) ? $result : 0;
            } catch (\Exception $e) {
                $message->setError(Error::fromException($e));
                $status = 1;
            }

            if (!$this->debug) {
                $message->setOutput(ob_get_clean());
            }

            exit($status);
        }

        // connect to shared memory
        $shm = $this->factory->createSharedMemory($pid);

        return $this->forks[$pid] = $this->factory->createFork($pid, $shm, $this->debug);
    }
766454
function() {
      var resultDeferred = $.Deferred();
      if (this.isDisposed()) {
        var rejectArguments = Array.prototype.slice.call(arguments);
        rejectArguments.push('Data Behavior disposed, aborting.');
        resultDeferred.reject.apply(resultDeferred, rejectArguments);
      } else {
        resultDeferred.resolve.apply(resultDeferred, arguments);
      }
      return resultDeferred.promise();
    }
1313594
def with_fork_context(self, func):
    """"""
    res = self._native.lib.scheduler_fork_context(self._scheduler, Function(self._to_key(func)))
    return self._raise_or_return(res)
1192355
function() {
                        var args = Array.prototype.slice.call(arguments, 0);
                        deferredObject.reject.apply(null, ctxArgs.concat(args));
                    }
736376
public <T> RPromise<T> deferredPromise () {
    return new RPromise<T>() {
      @Override public void succeed (final T value) {
        invokeLater(new Runnable() {
          public void run () { superSucceed(value); }
        });
      }
      @Override public void fail (final Throwable cause) {
        invokeLater(new Runnable() {
          public void run () { superFail(cause); }
        });
      }
      private void superSucceed (T value) { super.succeed(value); }
      private void superFail (Throwable cause) { super.fail(cause); }
    };
  }
930329
function(name, brk, debugChildren) {
		var deferred = Q.defer();
		var args = process.argv;
		
		grunt.task.clearQueue();
		
		var tasks = args.slice(args.indexOf(name) + 1);
		
		if (debugChildren) {
			tasks.unshift('debug:hook' + (brk ? '-break' : ''));
		}
		
		var child = child_process.fork(
			args[1],
			tasks,
			{
				execArgv: [
					brk
						? '--debug-brk'
						: '--debug'
				]
			}
		);
		
		child.on('exit', function(code) {
			if (code == 0) {
				deferred.resolve();
			}
			else {
				deferred.reject(code);
			}
		});
		
		return deferred.promise;
	}
343675
function processor() {
    var destination = unified()
    var length = attachers.length
    var index = -1

    while (++index < length) {
      destination.use.apply(null, attachers[index])
    }

    destination.data(extend(true, {}, namespace))

    return destination
  }
555976
function($done) {
  function procType(kv, $_done) {
    var jobType=kv[0], func=kv[1]
    JOBS.process(jobType, func._concurrent, func)
    $_done()
  }

  // TODO: wouldn't need to do this if async.forEach() took an object
  var _procs = _.zip(_.keys(__processors), _.values(__processors))

  async.forEach(_procs, procType, function(err) {
    if (err) return $done(err);
    __running.process = true
    $done()
  })
}
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;
            };
        }
500345
function deferred(mediaObject, params, prevRpc, callback) {
  var promises = [];

  if (mediaObject != undefined)
    promises.push(mediaObject);

  for (var key in params) {
    var param = params[key];
    if (param !== undefined)
      promises.push(param);
  };

  if (prevRpc != undefined)
    promises.push(prevRpc);

  return promiseCallback(Promise.all(promises), callback);
}
380291
def _defer_to_worker(deliver, worker, work, *args, **kwargs):
    
    deferred = Deferred()

    def wrapped_work():
        try:
            result = work(*args, **kwargs)
        except BaseException:
            f = Failure()
            deliver(lambda: deferred.errback(f))
        else:
            deliver(lambda: deferred.callback(result))
    worker.do(wrapped_work)
    return deferred
1084147
function ( obj, arg, state ) {
		if ( obj.state > promise.state.PENDING ) {
			return;
		}

		obj.value = arg;
		obj.state = state;

		if ( !obj.deferred ) {
			promise.delay( function () {
				obj.process();
			});

			obj.deferred = true;
		}

		return obj;
	}
1267266
function processItem(path) {
            var deferred = new $.Deferred(),
                fileEntry = FileSystem.getDirectoryForPath(path);

            fileEntry.exists(function (err, exists) {
                if (!err && exists) {
                    deferred.resolve();
                } else {
                    deferred.reject();
                }
            });

            return deferred.promise();
        }
808618
def os_forkpty_wrapper():
    """"""
    pid = None
    prepare_to_fork_acquire()
    try:
        pid, fd = _orig_os_forkpty()
    finally:
        if pid == 0:
            child_after_fork_release()
        else:
            parent_after_fork_release()
    return pid, fd
1353979
function (i) {
        var deferred = $.Deferred();
        deferreds.push(deferred);

        var originalVal = changes[i][3];
        var lowercaseVal = typeof originalVal === 'string' ? originalVal.toLowerCase() : null;

        return function (source) {
          var found = false;
          for (var s = 0, slen = source.length; s < slen; s++) {
            if (originalVal === source[s]) {
              found = true; //perfect match
              break;
            }
            else if (lowercaseVal === source[s].toLowerCase()) {
              changes[i][3] = source[s]; //good match, fix the case
              found = true;
              break;
            }
          }
          if (!found) {
            changes[i] = null;
          }
          deferred.resolve();
        }
      }
1150640
function processItemAsync(runner, currentValidation, key, context) {
  return Promise.resolve(true).then(function() {
    return processItem(runner, currentValidation, key, context)
  });
}
445797
function() {
    var pending = [],
        value, deferred;

    deferred = {

      resolve: function(val) {
        if (pending) {
          var callbacks = pending;
          pending = undefined;
          value = ref(val);

          if (callbacks.length) {
            nextTick(function() {
              var callback;
              for (var i = 0, ii = callbacks.length; i < ii; i++) {
                callback = callbacks[i];
                value.then(callback[0], callback[1]);
              }
            });
          }
        }
      },


      reject: function(reason) {
        deferred.resolve(reject(reason));
      },


      promise: {
        then: function(callback, errback) {
          var result = defer();

          var wrappedCallback = function(value) {
            try {
              result.resolve((callback || defaultCallback)(value));
            } catch(e) {
              exceptionHandler(e);
              result.reject(e);
            }
          };

          var wrappedErrback = function(reason) {
            try {
              result.resolve((errback || defaultErrback)(reason));
            } catch(e) {
              exceptionHandler(e);
              result.reject(e);
            }
          };

          if (pending) {
            pending.push([wrappedCallback, wrappedErrback]);
          } else {
            value.then(wrappedCallback, wrappedErrback);
          }

          return result.promise;
        }
      }
    };

    return deferred;
  }