改名
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Server\Tasker;
|
namespace Server\Tasker;
|
||||||
|
|
||||||
|
use Kiri\Kiri;
|
||||||
use Note\Inject;
|
use Note\Inject;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri\Abstracts\BaseObject;
|
use Kiri\Abstracts\BaseObject;
|
||||||
@@ -21,10 +22,9 @@ class AsyncTaskExecute extends BaseObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var SwooleServerInterface
|
* @var SwooleServerInterface|null
|
||||||
*/
|
*/
|
||||||
#[Inject(SwooleServerInterface::class)]
|
public ?SwooleServerInterface $server = null;
|
||||||
public SwooleServerInterface $server;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,6 +64,9 @@ class AsyncTaskExecute extends BaseObject
|
|||||||
*/
|
*/
|
||||||
public function execute(OnTaskInterface|string $handler, array $params = [], int $workerId = null)
|
public function execute(OnTaskInterface|string $handler, array $params = [], int $workerId = null)
|
||||||
{
|
{
|
||||||
|
if (!$this->server) {
|
||||||
|
$this->server = Kiri::getDi()->get(SwooleServerInterface::class);
|
||||||
|
}
|
||||||
if ($workerId === null || $workerId <= $this->server->setting['worker_num']) {
|
if ($workerId === null || $workerId <= $this->server->setting['worker_num']) {
|
||||||
$workerId = random_int($this->server->setting['worker_num'] + 1, $this->server->setting['task_worker_num']);
|
$workerId = random_int($this->server->setting['worker_num'] + 1, $this->server->setting['task_worker_num']);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user