{@inheritDoc}
@see \SimpleConcurrent\SimpleRequestInterface::getPromise()
489195
public function getPromise(): PromiseInterface
    {
        if (! $this->requestOrign && ! $this->promise) throw new RequestBuildExpection('please give a request.');
        if (! $this->promise) {
            $this->promise = $this->_getClient()->sendAsync($this->requestOrign, $this->requestOption);
        }
        if ($this->responseIsJson && ! $this->isJsonCallbackPassed) {
            array_unshift($this->callbackOfSuccess, function ($res) {
                return json_decode($res, true);
            });
            $this->isJsonCallbackPassed = true;
        }
        return $this->promise;
    }
777623
public function get($queue = "", $noAck = false)
    {
        if ($this->getDeferred !== null) {
            throw new ChannelException("Another 'basic.get' already in progress. You should use 'basic.consume' instead of multiple 'basic.get'.");
        }

        $response = $this->getImpl($queue, $noAck);

        if ($response instanceof PromiseInterface) {
            $this->getDeferred = new Deferred();

            $response->done(function ($frame) {
                if ($frame instanceof MethodBasicGetEmptyFrame) {
                    // deferred has to be first nullified and then resolved, otherwise results in race condition
                    $deferred = $this->getDeferred;
                    $this->getDeferred = null;
                    $deferred->resolve(null);

                } elseif ($frame instanceof MethodBasicGetOkFrame) {
                    $this->getOkFrame = $frame;
                    $this->state = ChannelStateEnum::AWAITING_HEADER;

                } else {
                    throw new \LogicException("This statement should never be reached.");
                }
            });

            return $this->getDeferred->promise();

        } elseif ($response instanceof MethodBasicGetEmptyFrame) {
            return null;

        } elseif ($response instanceof MethodBasicGetOkFrame) {
            $this->state = ChannelStateEnum::AWAITING_HEADER;

            $headerFrame = $this->getClient()->awaitContentHeader($this->getChannelId());
            $this->headerFrame = $headerFrame;
            $this->bodySizeRemaining = $headerFrame->bodySize;
            $this->state = ChannelStateEnum::AWAITING_BODY;

            while ($this->bodySizeRemaining > 0) {
                $bodyFrame = $this->getClient()->awaitContentBody($this->getChannelId());

                $this->bodyBuffer->append($bodyFrame->payload);
                $this->bodySizeRemaining -= $bodyFrame->payloadSize;

                if ($this->bodySizeRemaining < 0) {
                    $this->state = ChannelStateEnum::ERROR;
                    $this->client->disconnect(Constants::STATUS_SYNTAX_ERROR, $errorMessage = "Body overflow, received " . (-$this->bodySizeRemaining) . " more bytes.");
                    throw new ChannelException($errorMessage);
                }
            }

            $this->state = ChannelStateEnum::READY;

            $message = new Message(
                null,
                $response->deliveryTag,
                $response->redelivered,
                $response->exchange,
                $response->routingKey,
                $this->headerFrame->toArray(),
                $this->bodyBuffer->consume($this->bodyBuffer->getLength())
            );

            $this->headerFrame = null;

            return $message;

        } else {
            throw new \LogicException("This statement should never be reached.");
        }
    }
41470
protected function send(PromiseInterface $promise)
    {
        if (!$promise->isPending())
        {
            return $promise;
        }

        $this->channel->send(
            $this->name,
            $this->message,
            Channel::MODE_STANDARD,
            function($value) use($promise) {
                $promise->resolve($value);
            },
            function($ex) use($promise) {
                $promise->reject($ex);
            },
            function($ex) use($promise) {
                $this->retryOrReset($promise, $ex);
            },
            $this->params['timeout']
        );

        return $promise;
    }
983767
function resolveOrEnqueuePromise( PromiseInterface $promise, callable $resultCallback = null )
	{
		if ($this->next_async_request)
		{
			$promise = $promise->then(function($result) use ($resultCallback) {
				return $resultCallback ? $resultCallback($result) : null;
			});
			$this->next_async_request->setPromise($promise);
			return $this->next_async_request = null;
		}
		return $resultCallback ? $resultCallback($promise->wait()) : null;
	}
323901
function handlePromise(query, q, model, resultsPerPage) {
  return Promise.all([
    query.exec(),
    model.count(q).exec()
  ]).spread(function(results, count) {
    return [
      results,
      Math.ceil(count / resultsPerPage) || 1,
      count
    ]
  });
}
1301270
private function getNonce(string $uri): Promise {
        if (empty($this->nonces)) {
            return $this->requestNonce($uri);
        }

        return new Success(array_shift($this->nonces));
    }
793621
function init(\CharlotteDunois\Livia\Client $client): \React\Promise\ExtendedPromiseInterface {
        $this->client = $client;
        $this->attachListeners();
        
        return $this->db->execute('CREATE TABLE IF NOT EXISTS settings (guild VARCHAR(20) NOT NULL, settings TEXT NOT NULL, PRIMARY KEY (guild))')
            ->then(function () {
                return $this->db->execute('SELECT * FROM settings')->then(function (\Plasma\StreamQueryResultInterface $result) {
                    return $result->all()->then(function (\Plasma\QueryResultInterface $result) {
                        $rows = $result->getRows();
                        
                        foreach($rows as $row) {
                            $this->loadRow($row);
                        }
                        
                        if($this->settings->has('global')) {
                            return null;
                        }
                        
                        return $this->create('global')->then(function () {
                            return null;
                        });
                    });
                });
            });
    }
694612
function _resolvePromises (opts, val) {
  opts = opts || {}
  var duplicate = opts.duplicate
  if (is(Array, val)) {
    return Promise.all(duplicate ? concat([], val) : val)
  } else if (duplicate && is(Object, val) && !is(Function, val.then)) {
    return Object.assign({}, val)
  }
  return val
}
144121
function getPromise(provider, extension) {
			var contentTypeIds = provider.getProperty("contentType") || provider.getProperty("contentTypes"), //$NON-NLS-1$ //$NON-NLS-0$
			    fileTypes = provider.getProperty("fileTypes"); // backwards compatibility //$NON-NLS-0$
			if (contentTypeIds) {
				return Deferred.when(contentTypeService.isSomeExtensionOf(contentType, contentTypeIds)).then(
					function (isMatch) {
						return isMatch ? provider : null;
					});
			} else if (extension && fileTypes && fileTypes.indexOf(extension) !== -1) {
				var d = new Deferred();
				d.resolve(provider);
				return d;
			}
			return null;
		}
1051399
private function getPromises(PushInterface $push) {
        foreach ($push->getRecipientsFor($this) as $recipient) {
            yield $recipient->getIdentifier() => $this->createPromiseForPush($push, $recipient);
        }
    }
761867
private function emit($value): Promise
    {
        if ($this->complete) {
            throw new \Error("Iterators cannot emit values after calling complete");
        }

        if ($value instanceof ReactPromise) {
            $value = Promise\adapt($value);
        }

        if ($value instanceof Promise) {
            $deferred = new Deferred;
            $value->onResolve(function ($e, $v) use ($deferred) {
                if ($this->complete) {
                    $deferred->fail(
                        new \Error("The iterator was completed before the promise result could be emitted")
                    );
                    return;
                }

                if ($e) {
                    $this->fail($e);
                    $deferred->fail($e);
                    return;
                }

                $deferred->resolve($this->emit($v));
            });

            return $deferred->promise();
        }

        $this->values[] = $value;
        $this->backPressure[] = $pressure = new Deferred;

        if ($this->waiting !== null) {
            $waiting = $this->waiting;
            $this->waiting = null;
            $waiting->resolve(true);
        }

        return $pressure->promise();
    }
140347
private function createPromise()
    {
        // Create the promise
        $promise = call_user_func($this->promiseCreator, $this);
        $this->promiseCreator = null;

        // Cleans up the promise state and references.
        $cleanup = function () {
            $this->before = $this->client = $this->queue = null;
        };

        // When done, ensure cleanup and that any remaining are processed.
        return $promise->then(
            function () use ($cleanup)  {
                return Promise\promise_for($this->flushQueue())
                    ->then($cleanup);
            },
            function ($reason) use ($cleanup)  {
                $cleanup();
                return Promise\rejection_for($reason);
            }
        );
    }
1273897
function commit(): \React\Promise\PromiseInterface {
        return $this->query('COMMIT')->then(function () {
            $this->driver->endTransaction();
            $this->client->checkinConnection($this->driver);
            $this->driver = null;
        });
    }
941605
function makePromise(requestInstance, promiseFactoryFn) {

  // Resolver function wich assigns the promise (resolve, reject) functions
  // to the requestInstance
  function Resolver(resolve, reject) {
    this._resolve = resolve;
    this._reject = reject;
  }

  return promiseFactoryFn(Resolver.bind(requestInstance));
}
661607
public function requestAsync(
        string $method,
        $params = [],
        ?callable $fulfilled = null,
        ?callable $rejected = null) : Promise\Promise
    {
        $promise = $this->client
            ->postAsync($this->path, $this->makeJson($method, $params));

        $promise->then(function ($response) use ($fulfilled) {
            $this->onSuccess($response, $fulfilled);
        });

        $promise->otherwise(function ($exception) use ($rejected) {
            try {
                exception()->handle($exception);
            } catch (Throwable $exception) {
                $this->onError($exception, $rejected);
            }
        });

        $this->promises[] = $promise;

        return $promise;
    }
830735
public function channel($bind = []): Observable
    {
        $this->bunny = $this->bunny ?? new BaseAsynchClient($this->loop, $this->configuration);

        if (!\is_array($bind)) {
            $bind = \func_get_args();
        }

        return Observable::fromPromise(
            $this->bunny
                ->connect()
                ->then(function (BaseAsynchClient $client) {
                    return $client->channel();
                })
                ->then(function (Channel $channel) use ($bind) {
                    foreach ($bind as $obj) {
                        $obj->setChannel($channel);
                    }

                    return $channel;
                })
        );
    }
1114765
static function now($val, $default=null) {
		if ( $val instanceof PromiseInterface ) {
			return ( $val->getState() === PromiseInterface::PENDING ) ? $default : $val->wait();
		}
		return $val;
	}