class PoolId {
public static function get($id = null) {
if ($id === null) {
$id = \Swoole\Coroutine::getCid();
}
$pid = \Swoole\Coroutine::getPcid($id);
if ($pid < 0) {
return $id;
}
return self::get($pid);
}
}
转载原创文章请注明,转载自:
Swoole获取最顶层协程ID的方法
-
冯俊豪博客
(https://www.junphp.com/details/503.jsp)