Files
kiri-core/kiri-engine/Async.php
T
as2252258 d8222366b1 Revert "改名"
This reverts commit fdf58326
2022-01-17 18:45:00 +08:00

45 lines
766 B
PHP

<?php
namespace Kiri;
use Exception;
use Kiri\Abstracts\Component;
use Kiri\Server\ServerManager;
use Kiri\Task\AsyncTaskExecute;
use Kiri;
/**
* Class Async
* @package Kiri
*/
class Async extends Component
{
private static array $_absences = [];
/**
* @param string $name
* @param string $handler
*/
public function addAsync(string $name, string $handler)
{
static::$_absences[$name] = $handler;
}
/**
* @param string $name
* @param array $params
* @throws Exception
*/
public function dispatch(string $name, array $params = [])
{
$context = di(AsyncTaskExecute::class);
$context->execute(static::$_absences[$name], $params);
}
}