Since: 8.1

final class Fiber (View source)

Methods

__construct(callable $callback)

No description

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()}.

mixed
throw(Throwable $exception)

Throws the given exception into the fiber from {Fiber::suspend()}.

bool
isStarted()

No description

bool
isSuspended()

No description

bool
isRunning()

No description

bool
isTerminated()

No description

mixed
getReturn()

No description

static Fiber|null
getCurrent()

No description

static mixed
suspend(mixed $value = null)

Suspend execution of the fiber. The fiber may be resumed with {Fiber::resume()} or {Fiber::throw()}.

Details

__construct(callable $callback)

No description

Parameters

callable $callback

Function to invoke when starting the fiber.

mixed start(mixed ...$args)

Starts execution of the fiber. Returns when the fiber suspends or terminates.

Parameters

mixed ...$args

Arguments passed to fiber function.

Return Value

mixed

Value from the first suspension point or NULL if the fiber returns.

Exceptions

FiberError
Throwable

mixed resume(mixed $value = null)

Resumes the fiber, returning the given value from {Fiber::suspend()}.

Returns when the fiber suspends or terminates.

Parameters

mixed $value

Return Value

mixed

Value from the next suspension point or NULL if the fiber returns.

Exceptions

FiberError
Throwable

mixed throw(Throwable $exception)

Throws the given exception into the fiber from {Fiber::suspend()}.

Returns when the fiber suspends or terminates.

Parameters

Throwable $exception

Return Value

mixed

Value from the next suspension point or NULL if the fiber returns.

Exceptions

FiberError
Throwable

bool isStarted()

No description

Return Value

bool

True if the fiber has been started.

bool isSuspended()

No description

Return Value

bool

True if the fiber is suspended.

bool isRunning()

No description

Return Value

bool

True if the fiber is currently running.

bool isTerminated()

No description

Return Value

bool

True if the fiber has completed execution (returned or threw).

mixed getReturn()

No description

Return Value

mixed

Return value of the fiber callback. NULL is returned if the fiber does not have a return statement.

Exceptions

FiberError

static Fiber|null getCurrent()

No description

Return Value

Fiber|null

Returns the currently executing fiber instance or NULL if in {main}.

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}.

Parameters

mixed $value

Value to return from {\Fiber::resume()} or {\Fiber::throw()}.

Return Value

mixed

Value provided to {\Fiber::resume()}.

Exceptions

FiberError
Throwable