mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
feat(Architecture): 添加架构就绪状态等待功能
- 新增 `_readyTcs` 字段用于跟踪架构初始化状态 - 添加 `IsReady` 属性检查当前架构是否已就绪 - 在架构进入 Ready 阶段时释放 Ready await - 实现 `WaitUntilReadyAsync()` 方法支持异步等待架构初始化完成 - [skip ci]
This commit is contained in:
parent
9808367aa5
commit
27bc481577
@ -86,7 +86,9 @@ public abstract class Architecture(
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
private readonly TaskCompletionSource _readyTcs = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
public bool IsReady => CurrentPhase == ArchitecturePhase.Ready;
|
||||
/// <summary>
|
||||
/// 待初始化组件的去重集合
|
||||
/// </summary>
|
||||
@ -553,9 +555,18 @@ public abstract class Architecture(
|
||||
|
||||
_mInitialized = true;
|
||||
EnterPhase(ArchitecturePhase.Ready);
|
||||
|
||||
// 🔥 释放 Ready await
|
||||
_readyTcs.TrySetResult();
|
||||
|
||||
_logger.Info($"Architecture {GetType().Name} is ready - all components initialized");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 等待架构初始化完成(Ready 阶段)
|
||||
/// </summary>
|
||||
public Task WaitUntilReadyAsync()
|
||||
{
|
||||
return IsReady ? Task.CompletedTask : _readyTcs.Task;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user