/** * Examines the value yielded from the generator and prepares the next step in interation. * * @param mixed $yielded */ private function next($yielded) { if (!$this->generator->valid()) { $result = $this->generator->getReturn(); if ($result instanceof Awaitable) { $this->reject(new AwaitableReturnedError($result)); return; } if ($result instanceof Generator) { $this->reject(new GeneratorReturnedError($result)); return; } $this->resolve($result); return; } $this->busy = true; if ($yielded instanceof Generator) { $yielded = new self($yielded); } $this->current = $yielded; if ($yielded instanceof Awaitable) { $yielded->done($this->send, $this->capture); } else { Loop\queue($this->send, $yielded); } $this->busy = false; }
/** * Examines the value yielded from the generator and prepares the next step in interation. * * @param mixed $yielded */ private function next($yielded) { if (!$this->generator->valid()) { $this->resolve($this->generator->getReturn()); return; } if ($yielded instanceof Generator) { $yielded = new self($yielded); } $this->current = $yielded; if ($yielded instanceof Awaitable) { $yielded->done($this->send, $this->capture); } else { Loop\queue($this->send, $yielded); } }
/** * Examines the value yielded from the generator and prepares the next step in interation. * * @param mixed $yielded */ private function next($yielded) { if ($yielded instanceof Generator) { $yielded = new self($yielded); } if ($yielded instanceof PromiseInterface) { $yielded->done($this->send, $this->capture); } else { Loop\queue($this->send, $yielded); } }