Files
XCEngine/docs/api/threading/lambda-task/execute.md
ssdfasd f427699ac6 refactor: improve test infrastructure and fix OpenGL GLAD initialization
- 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
2026-03-23 00:43:02 +08:00

41 lines
892 B
Markdown

# LambdaTask::Execute
```cpp
void Execute() override
```
执行封装的可调用对象。调用时执行构造时传入的 lambda 或可调用函数。
**参数:**
**返回:**
**注意:**
- 如果封装的可调用对象抛出异常,异常会向上传播到 TaskSystem。
- 任务系统的工作线程不会捕获此类异常。
**示例:**
```cpp
// 创建并提交 LambdaTask
TaskSystem::Get().Submit(
std::make_unique<LambdaTask<std::function<void()>>>(
[]() {
printf("Task executed!\n");
},
TaskPriority::Normal
)
);
// 使用便捷重载直接提交
TaskSystem::Get().Submit([]() {
int result = ComputeHeavyWork();
printf("Result: %d\n", result);
}, TaskPriority::High);
```
## 相关文档
- [LambdaTask 总览](lambdatask.md) - 返回类总览
- [ITask::Execute](../task/execute.md) - 基类方法文档