Suspension
in
Should be used to run and suspend the event loop instead of directly interacting with fibers.
Example
$suspension = EventLoop::getSuspension();
$promise->then(
fn (mixed $value) => $suspension->resume($value),
fn (Throwable $error) => $suspension->throw($error)
);
$suspension->suspend();
Tags
Table of Contents
Methods
- resume() : void
- suspend() : T
- Returns the value provided to {@see resume()} or throws the exception provided to {@see throw()}.
- throw() : void
- Throws the given exception from the call to {@see suspend()}.
Methods
resume()
public
resume([T $value = null ]) : void
Parameters
- $value : T = null
-
The value to return from the call to suspend().
suspend()
Returns the value provided to {@see resume()} or throws the exception provided to {@see throw()}.
public
suspend() : T
Return values
Tthrow()
Throws the given exception from the call to {@see suspend()}.
public
throw(Throwable $throwable) : void
Parameters
- $throwable : Throwable