Amp\Internal\Placeholder::resolve PHP Method

resolve() private method

private resolve ( mixed $value = null )
$value mixed
    private function resolve($value = null)
    {
        if ($this->resolved) {
            throw new \Error("Promise has already been resolved");
        }
        $this->resolved = true;
        $this->result = $value;
        if ($this->onResolved === null) {
            return;
        }
        $onResolved = $this->onResolved;
        $this->onResolved = null;
        if ($this->result instanceof Promise) {
            $this->result->when($onResolved);
            return;
        }
        try {
            $onResolved(null, $this->result);
        } catch (\Throwable $exception) {
            Loop::defer(static function () use($exception) {
                throw $exception;
            });
        }
    }