public function cancel(Throwable $reason = null)
{
if (!$this->isPending()) {
return;
}
if (null === $reason) {
$reason = new TerminatedException();
}
parent::cancel($reason);
if ($this->current instanceof Awaitable) {
$this->current->cancel($reason);
// Will continue execution by throwing into the generator.
}
}