fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling - Improve link styling with underline decoration - Hide leaf nodes from tree, only show directories - Fix log file path for packaged app
This commit is contained in:
39
docs/api/threading/task-group/waitfor.md
Normal file
39
docs/api/threading/task-group/waitfor.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# TaskGroup::WaitFor
|
||||
|
||||
```cpp
|
||||
bool WaitFor(std::chrono::milliseconds timeout)
|
||||
```
|
||||
|
||||
等待任务组中所有任务完成,可在超时后返回。
|
||||
|
||||
**参数:**
|
||||
- `timeout` - 最大等待时间
|
||||
|
||||
**返回:** `bool` - 所有任务在超时前完成返回 true,超时返回 false
|
||||
|
||||
**复杂度:** O(n)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
TaskGroup* group = TaskSystem::Get().CreateTaskGroup();
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
group->AddTask([i]() {
|
||||
Thread::Sleep(i * 100);
|
||||
printf("Task %d done\n", i);
|
||||
});
|
||||
}
|
||||
|
||||
if (group->WaitFor(std::chrono::seconds(1))) {
|
||||
printf("All tasks completed within 1 second\n");
|
||||
} else {
|
||||
printf("Timeout! Some tasks still running\n");
|
||||
printf("Progress: %.1f%%\n", group->GetProgress() * 100.0f);
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [TaskGroup 总览](task-group.md) - 返回类总览
|
||||
- [Wait](wait.md) - 无超时等待
|
||||
Reference in New Issue
Block a user