From 6cac882fb43a3fd2f897fcd22ac14c60906729d7 Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Sun, 5 Apr 2026 15:21:51 +0800 Subject: [PATCH] =?UTF-8?q?refactor(coroutine):=20=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E5=8D=8F=E7=A8=8B=E8=B0=83=E5=BA=A6=E5=99=A8=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E9=98=B6=E6=AE=B5=E8=AE=BF=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除私有字段 _executionStage,直接使用构造函数参数 executionStage - 更新 ExecutionStage 属性实现,直接返回构造函数参数 - 修改协程元数据设置时使用参数而非私有字段 - 调整等待指令判断逻辑,直接比较参数值 --- GFramework.Core/Coroutine/CoroutineScheduler.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/GFramework.Core/Coroutine/CoroutineScheduler.cs b/GFramework.Core/Coroutine/CoroutineScheduler.cs index 05fa1f06..b11a5e57 100644 --- a/GFramework.Core/Coroutine/CoroutineScheduler.cs +++ b/GFramework.Core/Coroutine/CoroutineScheduler.cs @@ -38,7 +38,6 @@ public sealed class CoroutineScheduler( new(); private readonly Dictionary _completionStatuses = new(); - private readonly CoroutineExecutionStage _executionStage = executionStage; private readonly Dictionary> _grouped = new(); private readonly ILogger _logger = LoggerFactoryResolver.Provider.CreateLogger(nameof(CoroutineScheduler)); private readonly Dictionary _metadata = new(); @@ -69,7 +68,7 @@ public sealed class CoroutineScheduler( /// /// 获取当前调度器代表的执行阶段。 /// - public CoroutineExecutionStage ExecutionStage => _executionStage; + public CoroutineExecutionStage ExecutionStage => executionStage; /// /// 获取活跃协程数量。 @@ -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 }; }