This commit is contained in:
xl
2023-06-12 15:31:44 +08:00
parent 599e353a28
commit 8248b418ad
4 changed files with 15 additions and 19 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ namespace Kiri\Server\Task;
use Kiri\Server\Constant;
use Kiri\Server\ServerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use ReflectionException;
@@ -73,7 +74,7 @@ class Task implements TaskInterface
public function dispatch(array|string|object $handler, ?int $workerId = null): void
{
/** @var Server $server */
$server = \Kiri::service()->get('server');
$server = \Kiri::getDi()->get(ServerInterface::class);
if (is_null($workerId)) {
$workerId = rand(0, $server->setting[Constant::OPTION_TASK_WORKER_NUM] - 1);
}