修复问题: - containers: HashMap 实现描述修正 - debug: XE_LOG 宏参数顺序修正 - memory: ProxyAllocator 统计示例修正, PoolAllocator allocate size 检查描述 - resources: ResourceManager 缺失 UnloadGroup 方法 - rhi: D3D12 格式枚举名称修正, Texture Format 枚举补全, ResourceStates 补充 - threading: TaskGroup GetProgress/Wait/Cancel 实现限制说明
42 lines
883 B
Markdown
42 lines
883 B
Markdown
# TaskGroup::Wait
|
||
|
||
```cpp
|
||
void Wait()
|
||
```
|
||
|
||
阻塞当前线程,等待任务组中所有任务完成。
|
||
|
||
**参数:** 无
|
||
|
||
**返回:** 无
|
||
|
||
**复杂度:** O(n),n 为任务数量
|
||
|
||
**注意:**
|
||
- 如果任务组已被取消,此方法将立即返回。
|
||
- 如果任务组中还有未执行且未被取消的任务,调用此方法将永久阻塞(这是当前实现的限制)。
|
||
- 建议使用 `WaitFor()` 代替以避免永久阻塞。
|
||
|
||
**示例:**
|
||
|
||
```cpp
|
||
TaskGroup* group = TaskSystem::Get().CreateTaskGroup();
|
||
|
||
for (int i = 0; i < 10; ++i) {
|
||
group->AddTask([i]() {
|
||
printf("Task %d running\n", i);
|
||
});
|
||
}
|
||
|
||
printf("Waiting for all tasks...\n");
|
||
group->Wait();
|
||
printf("All tasks completed!\n");
|
||
|
||
TaskSystem::Get().DestroyTaskGroup(group);
|
||
```
|
||
|
||
## 相关文档
|
||
|
||
- [TaskGroup 总览](task-group.md) - 返回类总览
|
||
- [WaitFor](waitfor.md) - 超时等待
|