mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-12 13:14:30 +08:00
refactor(coroutine): 简化协程调度器中的执行阶段访问
- 移除私有字段 _executionStage,直接使用构造函数参数 executionStage - 更新 ExecutionStage 属性实现,直接返回构造函数参数 - 修改协程元数据设置时使用参数而非私有字段 - 调整等待指令判断逻辑,直接比较参数值
This commit is contained in:
parent
ccffb121b3
commit
6cac882fb4
@ -38,7 +38,6 @@ public sealed class CoroutineScheduler(
|
|||||||
new();
|
new();
|
||||||
|
|
||||||
private readonly Dictionary<CoroutineHandle, CoroutineCompletionStatus> _completionStatuses = new();
|
private readonly Dictionary<CoroutineHandle, CoroutineCompletionStatus> _completionStatuses = new();
|
||||||
private readonly CoroutineExecutionStage _executionStage = executionStage;
|
|
||||||
private readonly Dictionary<string, HashSet<CoroutineHandle>> _grouped = new();
|
private readonly Dictionary<string, HashSet<CoroutineHandle>> _grouped = new();
|
||||||
private readonly ILogger _logger = LoggerFactoryResolver.Provider.CreateLogger(nameof(CoroutineScheduler));
|
private readonly ILogger _logger = LoggerFactoryResolver.Provider.CreateLogger(nameof(CoroutineScheduler));
|
||||||
private readonly Dictionary<CoroutineHandle, CoroutineMetadata> _metadata = new();
|
private readonly Dictionary<CoroutineHandle, CoroutineMetadata> _metadata = new();
|
||||||
@ -69,7 +68,7 @@ public sealed class CoroutineScheduler(
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取当前调度器代表的执行阶段。
|
/// 获取当前调度器代表的执行阶段。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CoroutineExecutionStage ExecutionStage => _executionStage;
|
public CoroutineExecutionStage ExecutionStage => executionStage;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取活跃协程数量。
|
/// 获取活跃协程数量。
|
||||||
@ -234,7 +233,7 @@ public sealed class CoroutineScheduler(
|
|||||||
_slots[slotIndex] = slot;
|
_slots[slotIndex] = slot;
|
||||||
_metadata[handle] = new CoroutineMetadata
|
_metadata[handle] = new CoroutineMetadata
|
||||||
{
|
{
|
||||||
ExecutionStage = _executionStage,
|
ExecutionStage = executionStage,
|
||||||
Group = group,
|
Group = group,
|
||||||
Priority = priority,
|
Priority = priority,
|
||||||
SlotIndex = slotIndex,
|
SlotIndex = slotIndex,
|
||||||
@ -756,8 +755,8 @@ public sealed class CoroutineScheduler(
|
|||||||
{
|
{
|
||||||
return instruction switch
|
return instruction switch
|
||||||
{
|
{
|
||||||
WaitForFixedUpdate => _executionStage == CoroutineExecutionStage.FixedUpdate,
|
WaitForFixedUpdate => executionStage == CoroutineExecutionStage.FixedUpdate,
|
||||||
WaitForEndOfFrame => _executionStage == CoroutineExecutionStage.EndOfFrame,
|
WaitForEndOfFrame => executionStage == CoroutineExecutionStage.EndOfFrame,
|
||||||
_ => true
|
_ => true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user