= 70100) { $emit = \Closure::fromCallable([$this, 'emit']); } else { $emit = function ($value): Awaitable { return $this->emit($value); }; } $result = $emitter($emit); if (!$result instanceof \Generator) { throw new \Error("The callable did not return a Generator"); } Loop::defer(function () use ($result) { $coroutine = new Coroutine($result); $coroutine->when(function ($exception, $value) { if ($this->resolved) { return; } if ($exception) { $this->fail($exception); return; } $this->resolve($value); }); }); } }