Revert "改名"

This reverts commit fdf58326
This commit is contained in:
2022-01-10 19:03:55 +08:00
parent 078e8338fe
commit 6eb7aa1fb0
+4 -6
View File
@@ -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);