public function await($promise = null, $unwrap = false)
    {
        if (null === $promise) {
            Deferred::runQueue();
            SyncPromise::runQueue();
            $this->cancellers = [];
            return null;
        }
        $promiseAdapter = $this->getWebonyxPromiseAdapter();

        $resolvedValue = null;
        $exception = null;
        if (!$this->isPromise($promise)) {
            throw new \InvalidArgumentException(sprintf('The "%s" method must be called with a Promise ("then" method).', __METHOD__));
        }

        try {
            $resolvedValue = $promiseAdapter->wait($promise);
        } catch (\Exception $reason) {
            $exception = $reason;
        }
        if ($exception instanceof \Exception) {
            if (!$unwrap) {
                return $exception;
            }
            throw $exception;
        }

        $hash = spl_object_hash($promise);
        unset($this->cancellers[$hash]);
        return $resolvedValue;
    }
public function await($promise = null, $unwrap = false)
    {
        if (null === $promise) {
            Deferred::runQueue();
            SyncPromise::runQueue();
            $this->cancellers = [];
            return null;
        }
        $promiseAdapter = $this->getWebonyxPromiseAdapter();

        $resolvedValue = null;
        $exception = null;
        if (!$this->isPromise($promise)) {
            throw new \InvalidArgumentException(sprintf('The "%s" method must be called with a Promise ("then" method).', __METHOD__));
        }

        try {
            $resolvedValue = $promiseAdapter->wait($promise);
        } catch (\Exception $reason) {
            $exception = $reason;
        }
        if ($exception instanceof \Exception) {
            if (!$unwrap) {
                return $exception;
            }
            throw $exception;
        }

        $hash = spl_object_hash($promise);
        unset($this->cancellers[$hash]);
        return $resolvedValue;
    }
{@inheritdoc}