GeWuYou e5e3a1c0ca feat(coroutine): 添加协程分组管理和优先级支持
- 实现协程分组功能,支持批量暂停、恢复和终止协程
- 添加协程优先级系统,支持从最低到最高的5个优先级级别
- 引入协程统计功能,跟踪启动、完成、失败数量及执行时间
- 添加FakeTimeSource用于协程测试的时间控制
- 实现按优先级排序的协程执行机制
- 添加协程执行时间戳记录功能
- 实现完整的协程统计报告生成功能
2026-03-06 12:34:12 +08:00

47 lines
1.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using GFramework.Core.Abstractions.coroutine;
namespace GFramework.Core.Tests.coroutine;
/// <summary>
/// 可控制的时间源,用于协程测试
/// </summary>
public sealed class FakeTimeSource : ITimeSource
{
/// <summary>
/// 获取当前累计时间
/// </summary>
public double CurrentTime { get; private set; }
/// <summary>
/// 获取上一帧的时间增量
/// </summary>
public double DeltaTime { get; private set; }
/// <summary>
/// 更新时间源
/// </summary>
public void Update()
{
// 在测试中Update 不做任何事情
// 时间推进由 Advance 方法控制
}
/// <summary>
/// 前进指定的时间
/// </summary>
/// <param name="deltaTime">时间增量(秒)</param>
public void Advance(double deltaTime)
{
DeltaTime = deltaTime;
CurrentTime += deltaTime;
}
/// <summary>
/// 重置时间源到初始状态
/// </summary>
public void Reset()
{
CurrentTime = 0;
DeltaTime = 0;
}
}