PHP8 纖程(Fiber)類

2023-08-21 16:09 更新

(PHP 8 >= 8.1.0)

簡(jiǎn)介

纖程(Fiber)代表了有完整棧、可中斷的功能。Fiber 可以從調(diào)用堆棧中的任何位置掛起,在 fiber 內(nèi)暫停執(zhí)行,直到稍后恢復(fù) fiber。

類摘要

final class Fiber {
/* 方法 */
public __construct(callable $callback)
public start(mixed ...$args): mixed
public resume(mixed $value = null): mixed
public throw(Throwable $exception): mixed
public getReturn(): mixed
public isStarted(): bool
public isSuspended(): bool
public isRunning(): bool
public isTerminated(): bool
public static suspend(mixed $value = null): mixed
public static getCurrent(): ?Fiber
}

參見(jiàn)

纖程概述

目錄

  • Fiber::__construct — 創(chuàng)建新的 Fiber 實(shí)例
  • Fiber::start — 啟動(dòng) fiber 的執(zhí)行
  • Fiber::resume — 使用值恢復(fù) fiber 的執(zhí)行
  • Fiber::throw — 用一個(gè)異常來(lái)恢復(fù) fiber 的執(zhí)行
  • Fiber::getReturn — 獲取 Fiber 的返回值
  • Fiber::isStarted — 確定 fiber 是否啟動(dòng)
  • Fiber::isSuspended — 確認(rèn) fiber 是否掛起
  • Fiber::isRunning — 確認(rèn) fiber 是否正在運(yùn)行
  • Fiber::isTerminated — 確認(rèn) fiber 是否終止
  • Fiber::suspend — 暫停當(dāng)前 fiber 的執(zhí)行
  • Fiber::getCurrent — 獲取當(dāng)前正在執(zhí)行的 Fiber 實(shí)例


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)