complete) { $onComplete(); return; } $this->onComplete[] = $onComplete; } public function complete() { if ($this->complete) { return; } $this->complete = true; foreach ($this->onComplete as $callback) { try { $callback(); } catch (\Throwable $exception) { Loop::defer(function () use ($exception) { throw $exception; // Rethrow to event loop error handler. }); } } $this->onComplete = null; } public function isComplete(): bool { return $this->complete; } }