Revert "改名"
This reverts commit fdf58326
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user