Files
XCEngine/docs/api/threading/task-system/update.md

39 lines
776 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# TaskSystem::Update
```cpp
void Update()
```
在主线程中处理主线程队列。执行所有通过 RunOnMainThread 提交的任务。
**参数:**
**返回:**
**线程安全:** ❌ (应在主线程调用)
**复杂度:** O(n)n 为队列中待执行任务数
**使用场景:**
- 在主循环中调用,确保 RunOnMainThread 提交的任务能够执行。
- 应在渲染前调用。
**示例:**
```cpp
// 主循环
while (application.IsRunning()) {
TaskSystem::Get().Update(); // 处理主线程任务
// 渲染
Renderer.BeginFrame();
RenderScene();
Renderer.EndFrame();
}
```
## 相关文档
- [TaskSystem 总览](task-system.md) - 返回类总览
- [RunOnMainThread](runonmainthread.md) - 提交主线程任务