parentId receive a coroutine id parameter

This commit is contained in:
huangzhhui 2020-06-09 19:19:34 +08:00
parent df0500b434
commit 1847f6bed0

View File

@ -46,9 +46,13 @@ class Coroutine
* *
* @see https://github.com/swoole/swoole-src/pull/2669/files#diff-3bdf726b0ac53be7e274b60d59e6ec80R940 * @see https://github.com/swoole/swoole-src/pull/2669/files#diff-3bdf726b0ac53be7e274b60d59e6ec80R940
*/ */
public static function parentId(): ?int public static function parentId(?int $coroutineId = null): ?int
{ {
$cid = SwooleCoroutine::getPcid(); if ($coroutineId) {
$cid = SwooleCoroutine::getPcid($coroutineId);
} else {
$cid = SwooleCoroutine::getPcid();
}
if ($cid === false) { if ($cid === false) {
return null; return null;
} }