qqq
This commit is contained in:
@@ -118,9 +118,7 @@ class AsyncServer implements ServerInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$container = Kiri::getDi();
|
$container = Kiri::getDi();
|
||||||
$task = $container->get(Task::class);
|
$container->get(Task::class)->initTaskWorker($this->server);
|
||||||
$container->bind(TaskInterface::class, $task);
|
|
||||||
$task->initTaskWorker($this->server);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-42
@@ -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
|
* @param Server $server
|
||||||
* @return void
|
* @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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Kiri\Server\Task;
|
||||||
|
|
||||||
|
use Kiri\Di\Inject\Container;
|
||||||
|
use Kiri\Server\ServerInterface;
|
||||||
|
|
||||||
|
class TaskExecute implements TaskInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ServerInterface
|
||||||
|
*/
|
||||||
|
#[Container(ServerInterface::class)]
|
||||||
|
public ServerInterface $server;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user