Files
kiri-core/Annotation/Asynchronous.php
T
2021-07-12 17:17:36 +08:00

45 lines
659 B
PHP

<?php
namespace Annotation;
use Exception;
use HttpServer\IInterface\Task;
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 mixed $class
* @param mixed|null $method
* @return bool
* @throws Exception
*/
public function execute(mixed $class, mixed $method = null): bool
{
$async = Snowflake::app()->getAsync();
$async->addAsync($this->name, $class);
return true;
}
}