function DriverSuspension::throw
Overrides Suspension::throw
File
-
vendor/
revolt/ event-loop/ src/ EventLoop/ Internal/ DriverSuspension.php, line 151
Class
- DriverSuspension
- @internal
Namespace
Revolt\EventLoop\InternalCode
public function throw(\Throwable $throwable) : void {
// Ignore spurious resumes to old dead {main} suspension
if ($this->deadMain) {
return;
}
if (!$this->pending) {
throw $this->error ?? new \Error('Must call suspend() before calling throw()');
}
$this->pending = false;
/** @var \Fiber|null $fiber */
$fiber = $this->fiberRef?->get();
if ($fiber) {
($this->queue)(static function () use ($fiber, $throwable) : void {
// The fiber may be destroyed with suspension as part of the GC cycle collector.
if (!$fiber->isTerminated()) {
$fiber->throw($throwable);
}
});
}
else {
// Suspend event loop fiber to {main}.
($this->interrupt)(static fn() => throw $throwable);
}
}