diff --git a/src/Core/Coroutine/GoWaitGroup.php b/src/Core/Coroutine/GoWaitGroup.php index b3355e80..5cbae76b 100644 --- a/src/Core/Coroutine/GoWaitGroup.php +++ b/src/Core/Coroutine/GoWaitGroup.php @@ -96,10 +96,10 @@ public function goApp(\Closure $callBack, ...$params) * var_dump($result); * * @param array $callBacks - * @param float $timeOut + * @param float $maxTimeOut * @return array */ - public static function batchParallelRunWait(array $callBacks, float $timeOut = 3.0): array + public static function batchParallelRunWait(array $callBacks, float $maxTimeOut = 3.0): array { $goWait = new static(); foreach ($callBacks as $key => $callBack) { @@ -115,7 +115,7 @@ public static function batchParallelRunWait(array $callBacks, float $timeOut = 3 } }); } - $result = $goWait->wait($timeOut); + $result = $goWait->wait($maxTimeOut); return $result; } diff --git a/src/Core/Coroutine/Parallel.php b/src/Core/Coroutine/Parallel.php index 19d9006b..8b50bd14 100644 --- a/src/Core/Coroutine/Parallel.php +++ b/src/Core/Coroutine/Parallel.php @@ -73,10 +73,10 @@ public function add(callable $callable, string $key = null) /** * runWait 并发后等待结果返回 * - * @param float $timeOut + * @param float $maxTimeOut * @return array */ - public function runWait(float $timeOut = 5.0) + public function runWait(float $maxTimeOut = 5.0) { if (empty($this->callbacks)) { return []; @@ -96,7 +96,7 @@ public function runWait(float $timeOut = 5.0) } if ($items) { - $res = GoWaitGroup::batchParallelRunWait($items, $timeOut); + $res = GoWaitGroup::batchParallelRunWait($items, $maxTimeOut); } $result = array_merge($result, $res ?? []); @@ -106,9 +106,9 @@ public function runWait(float $timeOut = 5.0) } /** - * 并发限制协程数量闭包处理 + * 并发限制协程数量闭包处理,无需等待结果返回 * - * @param int $concurrent 限制的并发协程数量 + * @param int $concurrent 限制的每批并发协程数量,防止瞬间产生大量的协程拖垮下游服务或者DB * @param array $list 数组 * @param \Closure $handleFn 回调处理 * @param float $sleepTime