fix(coroutine): 修复协程调度器中的潜在异常问题

- 在KillByTag方法中创建句柄数组副本以避免集合被修改的异常
- 修复Complete方法的缩进格式问题
- 为WaitCommandSwitch添加默认分支以处理未知类型的等待指令
This commit is contained in:
GeWuYou 2026-03-06 13:07:18 +08:00
parent 74f27ddfd5
commit e5bd972ee7

View File

@ -395,7 +395,8 @@ public sealed class CoroutineScheduler(
if (!_tagged.TryGetValue(tag, out var handles))
return 0;
return handles.Count(Kill);
var copy = handles.ToArray();
return copy.Count(Kill);
}
/// <summary>
@ -486,6 +487,9 @@ public sealed class CoroutineScheduler(
case WaitForCoroutine wfc:
wfc.Complete();
break;
default:
// 其他类型的等待指令不需要特殊处理
break;
}
s.State = CoroutineState.Running;