mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 00:39:00 +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();
|
||||
|
||||
private readonly Dictionary<CoroutineHandle, CoroutineCompletionStatus> _completionStatuses = new();
|
||||
private readonly CoroutineExecutionStage _executionStage = executionStage;
|
||||
private readonly Dictionary<string, HashSet<CoroutineHandle>> _grouped = new();
|
||||
private readonly ILogger _logger = LoggerFactoryResolver.Provider.CreateLogger(nameof(CoroutineScheduler));
|
||||
private readonly Dictionary<CoroutineHandle, CoroutineMetadata> _metadata = new();
|
||||
@ -69,7 +68,7 @@ public sealed class CoroutineScheduler(
|
||||
/// <summary>
|
||||
/// 获取当前调度器代表的执行阶段。
|
||||
/// </summary>
|
||||
public CoroutineExecutionStage ExecutionStage => _executionStage;
|
||||
public CoroutineExecutionStage ExecutionStage => executionStage;
|
||||
|
||||
/// <summary>
|
||||
/// 获取活跃协程数量。
|
||||
@ -234,7 +233,7 @@ public sealed class CoroutineScheduler(
|
||||
_slots[slotIndex] = slot;
|
||||
_metadata[handle] = new CoroutineMetadata
|
||||
{
|
||||
ExecutionStage = _executionStage,
|
||||
ExecutionStage = executionStage,
|
||||
Group = group,
|
||||
Priority = priority,
|
||||
SlotIndex = slotIndex,
|
||||
@ -756,8 +755,8 @@ public sealed class CoroutineScheduler(
|
||||
{
|
||||
return instruction switch
|
||||
{
|
||||
WaitForFixedUpdate => _executionStage == CoroutineExecutionStage.FixedUpdate,
|
||||
WaitForEndOfFrame => _executionStage == CoroutineExecutionStage.EndOfFrame,
|
||||
WaitForFixedUpdate => executionStage == CoroutineExecutionStage.FixedUpdate,
|
||||
WaitForEndOfFrame => executionStage == CoroutineExecutionStage.EndOfFrame,
|
||||
_ => true
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user