From 6eb7aa1fb03d041d2959bbfdc5ed65e706e6f5f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Mon, 10 Jan 2022 19:03:55 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E6=94=B9=E5=90=8D"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit fdf58326 --- Tasker/AsyncTaskExecute.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Tasker/AsyncTaskExecute.php b/Tasker/AsyncTaskExecute.php index a5158f6..e597f5b 100644 --- a/Tasker/AsyncTaskExecute.php +++ b/Tasker/AsyncTaskExecute.php @@ -50,18 +50,16 @@ class AsyncTaskExecute extends Component /** * @param OnTaskInterface|string $handler * @param array $params - * @param int|null $workerId + * @param int $workerId * @throws Exception */ - public function execute(OnTaskInterface|string $handler, array $params = [], int $workerId = null) + public function execute(OnTaskInterface|string $handler, array $params = [], int $workerId = -1) { if (!$this->server) { $this->server = Kiri::getDi()->get(SwooleServerInterface::class); } - if ($workerId === null || $workerId <= $this->server->setting['worker_num']) { - $workerNum = $this->server->setting['worker_num']; - $taskerNum = $workerNum + $this->server->setting['task_worker_num']; - $workerId = random_int($workerNum, $taskerNum - 1); + if ($workerId < 0 || $workerId > $this->server->setting['task_worker_num']) { + $workerId = random_int(0, $this->server->setting['task_worker_num'] - 1); } if (is_string($handler)) { $handler = $this->handle($handler, $params);