Fiber::suspend

(PHP 8 >= 8.1.0)

Fiber::suspend暫停當前 fiber 的執(zhí)行

說明

public static Fiber::suspend(mixed $value = null): mixed

暫停當前 fiber 的執(zhí)行。調用 Fiber::start()、 Fiber::resume()、 Fiber::throw() 將執(zhí)行切換到當前 fiber 時,提供給本方法的值,也將是這幾個方法所返回的值,

當 fiber 恢復后,此方法的返回值是 Fiber::resume() 所提供的值。 如果 fiber 使用 Fiber::throw() 恢復,則把傳入的異常在調用本方法的位置拋出。

如果此方法是用 fiber 外部調用,將會拋出 FiberError。

參數

value

該值會在調用 Fiber::start()Fiber::resume()、 Fiber::throw() 時作為返回值,并將執(zhí)行切換到當前 fiber。

返回值

提供給 Fiber::resume() 的值。