Files
kiri-core/Annotation/Asynchronous.php
T

44 lines
629 B
PHP
Raw Normal View History

2021-03-24 17:02:12 +08:00
<?php
namespace Annotation;
use Exception;
2021-05-03 03:48:52 +08:00
use HttpServer\IInterface\Task;
2021-03-24 17:02:12 +08:00
use Snowflake\Snowflake;
/**
* Class Asynchronous
* @package Annotation
* Task任务
*/
#[\Attribute(\Attribute::TARGET_CLASS)] class Asynchronous extends Attribute
{
/**
* Asynchronous constructor.
* @param string $name
*/
public function __construct(public string $name)
{
}
/**
* @param array $handler
* @return bool
* @throws Exception
*/
2021-05-03 03:48:52 +08:00
public function execute(mixed $class, mixed $method = null): mixed
2021-03-24 17:02:12 +08:00
{
$async = Snowflake::app()->getAsync();
2021-05-03 03:48:52 +08:00
$async->addAsync($this->name, $class);
2021-03-24 17:02:12 +08:00
return true;
}
}