- 重组文档目录结构: 每个模块的概述页移动到模块子目录 - 重命名 index.md 为 main.md - 修正所有模块文档中的错误: - math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式 - containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节 - core: 修复 types 链接错误 - debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI - memory: 修复头文件路径, malloc vs operator new, 新增方法文档 - resources: 修复 Shader/Texture 链接错误 - threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接 - 验证: fix_links.py 确认 0 个断裂引用
1.3 KiB
1.3 KiB
TaskSystem::Submit
将任务提交到任务系统调度执行。有两个重载版本。
重载 1: 提交 ITask 对象
uint64_t Submit(std::unique_ptr<ITask> task)
提交一个 ITask 对象到任务队列。
参数:
task- 要提交的任务对象
返回: uint64_t - 分配的任务 ID
复杂度: O(log n)
重载 2: 提交 lambda 任务
uint64_t Submit(std::function<void()>&& func, TaskPriority priority = TaskPriority::Normal)
将可调用对象包装为任务提交。
参数:
func- 要执行的可调用对象priority- 任务优先级,默认 TaskPriority::Normal
返回: uint64_t - 分配的任务 ID
复杂度: O(log n)
示例:
// 提交自定义任务
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 总览 - 返回类总览