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:
43
docs/api/threading/task-system/runonmainthread.md
Normal file
43
docs/api/threading/task-system/runonmainthread.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# TaskSystem::RunOnMainThread
|
||||
|
||||
```cpp
|
||||
void RunOnMainThread(std::function<void()>&& func)
|
||||
```
|
||||
|
||||
将任务提交到主线程队列。在主线程中调用 Update 时执行。
|
||||
|
||||
**参数:**
|
||||
- `func` - 要在主线程执行的函数
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**使用场景:**
|
||||
- 从工作线程回调需要更新 UI 或访问主线程资源。
|
||||
- 避免跨线程数据竞争。
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
// 在工作线程中
|
||||
void WorkerThreadCode() {
|
||||
int result = HeavyCompute();
|
||||
|
||||
// 将结果发送到主线程更新 UI
|
||||
TaskSystem::Get().RunOnMainThread([result]() {
|
||||
UI.UpdateResult(result);
|
||||
});
|
||||
}
|
||||
|
||||
// 在主线程中
|
||||
while (running) {
|
||||
TaskSystem::Get().Update(); // 处理主线程任务
|
||||
RenderFrame();
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [TaskSystem 总览](task-system.md) - 返回类总览
|
||||
- [Update](update.md) - 处理主线程队列
|
||||
Reference in New Issue
Block a user