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:
63
docs/api/threading/task-system/submit.md
Normal file
63
docs/api/threading/task-system/submit.md
Normal file
@@ -0,0 +1,63 @@
|
||||
# TaskSystem::Submit
|
||||
|
||||
将任务提交到任务系统调度执行。有两个重载版本。
|
||||
|
||||
## 重载 1: 提交 ITask 对象
|
||||
|
||||
```cpp
|
||||
uint64_t Submit(std::unique_ptr<ITask> task)
|
||||
```
|
||||
|
||||
提交一个 ITask 对象到任务队列。
|
||||
|
||||
**参数:**
|
||||
- `task` - 要提交的任务对象
|
||||
|
||||
**返回:** `uint64_t` - 分配的任务 ID
|
||||
|
||||
**复杂度:** O(log n)
|
||||
|
||||
## 重载 2: 提交 lambda 任务
|
||||
|
||||
```cpp
|
||||
uint64_t Submit(std::function<void()>&& func, TaskPriority priority = TaskPriority::Normal)
|
||||
```
|
||||
|
||||
将可调用对象包装为任务提交。
|
||||
|
||||
**参数:**
|
||||
- `func` - 要执行的可调用对象
|
||||
- `priority` - 任务优先级,默认 TaskPriority::Normal
|
||||
|
||||
**返回:** `uint64_t` - 分配的任务 ID
|
||||
|
||||
**复杂度:** O(log n)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
// 提交自定义任务
|
||||
class MyTask : public ITask {
|
||||
public:
|
||||
void Execute() override { printf("MyTask running\n"); }
|
||||
};
|
||||
uint64_t id1 = TaskSystem::Get().Submit(std::make_unique<MyTask>());
|
||||
|
||||
// 提交 lambda
|
||||
uint64_t id2 = TaskSystem::Get().Submit([]() {
|
||||
printf("Lambda task\n");
|
||||
});
|
||||
|
||||
uint64_t id3 = TaskSystem::Get().Submit([]() {
|
||||
HeavyCompute();
|
||||
}, TaskPriority::High);
|
||||
|
||||
// 等待任务完成
|
||||
TaskSystem::Get().Wait(id1);
|
||||
TaskSystem::Get().Wait(id2);
|
||||
TaskSystem::Get().Wait(id3);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [TaskSystem 总览](task-system.md) - 返回类总览
|
||||
Reference in New Issue
Block a user