From 5150b9027e6aa5bed3048df71be6c3d02d89fdcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Thu, 17 Aug 2023 17:04:55 +0800 Subject: [PATCH] qqq --- Abstracts/AsyncServer.php | 4 +-- Task/Task.php | 43 +------------------------------ Task/TaskExecute.php | 54 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 45 deletions(-) create mode 100644 Task/TaskExecute.php diff --git a/Abstracts/AsyncServer.php b/Abstracts/AsyncServer.php index ba85902..2691aa0 100644 --- a/Abstracts/AsyncServer.php +++ b/Abstracts/AsyncServer.php @@ -118,9 +118,7 @@ class AsyncServer implements ServerInterface return; } $container = Kiri::getDi(); - $task = $container->get(Task::class); - $container->bind(TaskInterface::class, $task); - $task->initTaskWorker($this->server); + $container->get(Task::class)->initTaskWorker($this->server); } diff --git a/Task/Task.php b/Task/Task.php index f77e633..2dcb095 100644 --- a/Task/Task.php +++ b/Task/Task.php @@ -15,16 +15,9 @@ use Kiri\Di\Inject\Container; /** * */ -class Task implements TaskInterface +class Task { - /** - * @var ServerInterface - */ - #[Container(ServerInterface::class)] - public ServerInterface $server; - - /** * @param Server $server * @return void @@ -76,38 +69,4 @@ class Task implements TaskInterface } - /** - * @param mixed $data - * @param float $timeout - * @param int $dstWorkerId - * @return mixed - */ - public function taskWait(mixed $data, float $timeout = 0.5, int $dstWorkerId = -1): mixed - { - return $this->server->taskwait($data, $timeout, $dstWorkerId); - } - - - /** - * @param array $tasks - * @param float $timeout - * @return false|array - */ - public function taskCo(array $tasks, float $timeout = 0.5): false|array - { - return $this->server->taskCo($tasks, $timeout); - } - - - /** - * @param array $tasks - * @param float $timeout - * @return false|array - */ - public function taskWaitMulti(array $tasks, float $timeout = 0.5): false|array - { - return $this->server->taskWaitMulti($tasks, $timeout); - } - - } diff --git a/Task/TaskExecute.php b/Task/TaskExecute.php new file mode 100644 index 0000000..48b73dc --- /dev/null +++ b/Task/TaskExecute.php @@ -0,0 +1,54 @@ +server->taskwait($data, $timeout, $dstWorkerId); + } + + + /** + * @param array $tasks + * @param float $timeout + * @return false|array + */ + public function taskCo(array $tasks, float $timeout = 0.5): false|array + { + return $this->server->taskCo($tasks, $timeout); + } + + + /** + * @param array $tasks + * @param float $timeout + * @return false|array + */ + public function taskWaitMulti(array $tasks, float $timeout = 0.5): false|array + { + return $this->server->taskWaitMulti($tasks, $timeout); + } + + +} \ No newline at end of file