This commit is contained in:
2025-07-11 11:50:54 +08:00
parent 251e05dbf7
commit c767a1745a
5 changed files with 97 additions and 22 deletions
+20 -5
View File
@@ -7,17 +7,34 @@ use Kiri\Server\ServerInterface;
class TaskExecute implements TaskInterface
{
/**
* @param OnTaskInterface $handler
* @param mixed $data
* @param int $dstWorkerId
* @param callable|null $finishFinishCallback
* @return void
*/
public function task(OnTaskInterface $handler, mixed $data, int $dstWorkerId = -1, ?callable $finishFinishCallback = null): void
{
$server = \Kiri::getDi()->get(ServerInterface::class);
$server->task([$handler, $data], $dstWorkerId, $finishFinishCallback);
}
/**
* @param OnTaskInterface $handler
* @param mixed $data
* @param float $timeout
* @param int $dstWorkerId
* @return mixed
*/
public function taskWait(mixed $data, float $timeout = 0.5, int $dstWorkerId = -1): mixed
public function taskWait(OnTaskInterface $handler, mixed $data, float $timeout = 0.5, int $dstWorkerId = -1): mixed
{
$server = \Kiri::getDi()->get(ServerInterface::class);
return $server->taskwait($data, $timeout, $dstWorkerId);
return $server->taskwait([$handler, $data], $timeout, $dstWorkerId);
}
@@ -45,6 +62,4 @@ class TaskExecute implements TaskInterface
return $server->taskWaitMulti($tasks, $timeout);
}
}
}