Revert "改名"
This reverts commit fdf58326
This commit is contained in:
@@ -50,18 +50,16 @@ class AsyncTaskExecute extends Component
|
|||||||
/**
|
/**
|
||||||
* @param OnTaskInterface|string $handler
|
* @param OnTaskInterface|string $handler
|
||||||
* @param array $params
|
* @param array $params
|
||||||
* @param int|null $workerId
|
* @param int $workerId
|
||||||
* @throws Exception
|
* @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) {
|
if (!$this->server) {
|
||||||
$this->server = Kiri::getDi()->get(SwooleServerInterface::class);
|
$this->server = Kiri::getDi()->get(SwooleServerInterface::class);
|
||||||
}
|
}
|
||||||
if ($workerId === null || $workerId <= $this->server->setting['worker_num']) {
|
if ($workerId < 0 || $workerId > $this->server->setting['task_worker_num']) {
|
||||||
$workerNum = $this->server->setting['worker_num'];
|
$workerId = random_int(0, $this->server->setting['task_worker_num'] - 1);
|
||||||
$taskerNum = $workerNum + $this->server->setting['task_worker_num'];
|
|
||||||
$workerId = random_int($workerNum, $taskerNum - 1);
|
|
||||||
}
|
}
|
||||||
if (is_string($handler)) {
|
if (is_string($handler)) {
|
||||||
$handler = $this->handle($handler, $params);
|
$handler = $this->handle($handler, $params);
|
||||||
|
|||||||
Reference in New Issue
Block a user