Fiber
final class Fiber (View source)
Fibers represent full-stack, interruptible functions. Fibers may be suspended from anywhere in the call-stack, pausing execution within the fiber until the fiber is resumed at a later time.
Methods
Creates a new Fiber instance
Starts execution of the fiber. Returns when the fiber suspends or terminates.
Resumes the fiber, returning the given value from {Fiber::suspend()}.
Determines if the fiber has started
Determines if the fiber is suspended
Determines if the fiber is running
Determines if the fiber has terminated
Gets the value returned by the Fiber
Gets the currently executing Fiber instance
Suspend execution of the fiber. The fiber may be resumed with {Fiber::resume()} or {Fiber::throw()}.
Details
__construct(callable $callback)
Creates a new Fiber instance
mixed
start(mixed ...$args)
Starts execution of the fiber. Returns when the fiber suspends or terminates.
mixed
resume(mixed $value = null)
Resumes the fiber, returning the given value from {Fiber::suspend()}.
Returns when the fiber suspends or terminates.
mixed
throw(Throwable $exception)
Throws the given exception into the fiber from {Fiber::suspend()}.
Returns when the fiber suspends or terminates.
bool
isStarted()
Determines if the fiber has started
bool
isSuspended()
Determines if the fiber is suspended
bool
isRunning()
Determines if the fiber is running
bool
isTerminated()
Determines if the fiber has terminated
mixed
getReturn()
Gets the value returned by the Fiber
static Fiber|null
getCurrent()
Gets the currently executing Fiber instance
static mixed
suspend(mixed $value = null)
Suspend execution of the fiber. The fiber may be resumed with {Fiber::resume()} or {Fiber::throw()}.
Cannot be called from {main}.