refactor: reorganize docs into plan/ and add skills/

This commit is contained in:
2026-03-18 17:49:22 +08:00
parent fc7c8f6797
commit 9bad996ecf
143 changed files with 13263 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
# LambdaTask
**命名空间**: `XCEngine::Threading`
**类型**: `class` (template)
**描述**: Lambda 任务封装模板类,允许使用 lambda 表达式创建任务,无需继承 ITask。
## 概述
`LambdaTask<Func>` 是一个模板封装类将任意可调用对象lambda、函数指针、std::function包装为 `ITask`。这大大简化了简短任务的创建。
## 模板参数
| 参数 | 描述 |
|------|------|
| `Func` | 可调用对象类型 |
## 构造方法
| 方法 | 描述 |
|------|------|
| `explicit LambdaTask(Func&& func, TaskPriority priority = TaskPriority::Normal)` | 构造 Lambda 任务 |
## 使用示例
```cpp
// 使用 lambda 创建任务
TaskSystem::Get().Submit(
std::make_unique<LambdaTask<std::function<void()>>>(
[]() {
printf("Hello from task!\n");
},
TaskPriority::Normal
)
);
// 或者直接使用 Submit 的便捷重载
TaskSystem::Get().Submit([]() {
printf("Direct lambda task!\n");
});
// 带依赖的任务
TaskSystem::Get().Submit<std::function<void()>>([]() {
// 任务内容
}, TaskPriority::High);
```
## 相关文档
- [ITask](./threading-task.md) - 任务基类
- [TaskGroup](./threading-task-group.md) - 任务组
- [TaskSystem](./threading-task-system.md) - 任务系统