mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-24 17:15:36 +08:00
fix tick coroutine bug, update to 3.1.13
This commit is contained in:
@@ -50,7 +50,7 @@ class Framework
|
|||||||
public const VERSION_ID = 718;
|
public const VERSION_ID = 718;
|
||||||
|
|
||||||
/** @var string 版本名称 */
|
/** @var string 版本名称 */
|
||||||
public const VERSION = '3.1.12';
|
public const VERSION = '3.1.13';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var RuntimePreferences 运行时偏好(环境信息&参数)
|
* @var RuntimePreferences 运行时偏好(环境信息&参数)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Schedule;
|
namespace ZM\Schedule;
|
||||||
|
|
||||||
|
use OneBot\Driver\Coroutine\Adaptive;
|
||||||
use ZM\Annotation\Framework\Tick;
|
use ZM\Annotation\Framework\Tick;
|
||||||
use ZM\Framework;
|
use ZM\Framework;
|
||||||
|
|
||||||
@@ -11,12 +12,19 @@ class Timer
|
|||||||
{
|
{
|
||||||
public static function tick(int $ms, callable $callback, int $times = 0): int
|
public static function tick(int $ms, callable $callback, int $times = 0): int
|
||||||
{
|
{
|
||||||
return Framework::getInstance()->getDriver()->getEventLoop()->addTimer($ms, $callback, $times);
|
return Framework::getInstance()->getDriver()->getEventLoop()->addTimer(
|
||||||
|
$ms,
|
||||||
|
fn (...$params) => Adaptive::getCoroutine() !== null ? Adaptive::getCoroutine()->create($callback, ...$params) : $callback(...$params),
|
||||||
|
$times
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function after(int $ms, callable $callback): int
|
public static function after(int $ms, callable $callback): int
|
||||||
{
|
{
|
||||||
return Framework::getInstance()->getDriver()->getEventLoop()->addTimer($ms, $callback);
|
return Framework::getInstance()->getDriver()->getEventLoop()->addTimer(
|
||||||
|
$ms,
|
||||||
|
fn (...$params) => Adaptive::getCoroutine() !== null ? Adaptive::getCoroutine()->create($callback, ...$params) : $callback(...$params)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function del(int $timer_id): void
|
public static function del(int $timer_id): void
|
||||||
|
|||||||
Reference in New Issue
Block a user