- Rename D3D12Enum.h to D3D12Enums.h for naming consistency - Fix OpenGL unit test GLAD initialization by using gladLoadGL() instead of gladLoadGLLoader(wglGetProcAddress) for fallback support - Migrate remaining tests to use gtest_discover_tests for granular test discovery (math, core, containers, memory, threading, debug, components, scene, resources, input, opengl) - Remove obsolete TEST_RESOURCES_DIR and copy_directory commands from OpenGL unit test CMakeLists (minimal/Res doesn't exist) - Update TEST_SPEC.md with performance metrics and per-module build/test commands for faster development workflow - Update CMake path references to use lowercase paths
58 lines
1.4 KiB
Markdown
58 lines
1.4 KiB
Markdown
# LambdaTask
|
||
|
||
**命名空间**: `XCEngine::Threading`
|
||
|
||
**类型**: `class` (template)
|
||
|
||
**头文件**: `XCEngine/Threading/LambdaTask.h`
|
||
|
||
**描述**: Lambda 任务封装模板类,允许使用 lambda 表达式创建任务,无需继承 ITask。
|
||
|
||
## 概述
|
||
|
||
`LambdaTask<Func>` 是一个模板封装类,将任意可调用对象(lambda、函数指针、std::function)包装为 `ITask`。这大大简化了简短任务的创建。
|
||
|
||
## 模板参数
|
||
|
||
| 参数 | 描述 |
|
||
|------|------|
|
||
| `Func` | 可调用对象类型 |
|
||
|
||
## 构造方法
|
||
|
||
| 方法 | 描述 |
|
||
|------|------|
|
||
| [`LambdaTask`](constructor.md) | 构造 Lambda 任务 |
|
||
|
||
## 继承方法
|
||
|
||
| 方法 | 描述 |
|
||
|------|------|
|
||
| [`Execute()`](execute.md) | 执行封装的可调用对象(继承自 ITask,纯虚方法重写) |
|
||
|
||
## 使用示例
|
||
|
||
```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");
|
||
});
|
||
```
|
||
|
||
## 相关文档
|
||
|
||
- [ITask](../task/task.md) - 任务基类
|
||
- [TaskGroup](../task-group/task-group.md) - 任务组
|
||
- [TaskSystem](../task-system/task-system.md) - 任务系统
|
||
- [../threading/threading.md](../threading.md) - 模块总览
|