/** * {@inheritdoc} */ public function isValid() : \Generator { while (null !== $this->awaitable) { (yield $this->awaitable); // Wait until last call has resolved. } if (null !== $this->placeholder) { $this->placeholder->ready(); } try { $this->placeholder = $this->queue->pull(); $this->current = (yield $this->awaitable = $this->placeholder->getAwaitable()); } catch (\Throwable $exception) { $this->current = $exception; throw $exception; } finally { $this->complete = $this->queue->isComplete(); $this->awaitable = null; } return !$this->complete; }
/** * {@inheritdoc} */ public function isComplete() : bool { return $this->queue->isComplete(); }