Files
XCEngine/docs/api/threading/lambda-task/constructor.md
ssdfasd d34d040563 Fix broken links in Threading API docs
Fix 14 broken cross-references in docs/api/threading/:
- lambda-task path: lambdatask -> lambda-task (5 occurrences)
- task-system-config path: tasksystemconfig -> task-system-config (6 occurrences)
- read-write-lock self-ref: readwritelock -> read-write-lock (6 occurrences)
- task-system cross-method: createtaskgroup/destroytaskgroup -> create-task-group/destroy-task-group
- thread cross-method: getcurrentid/getid -> get-current-id/get-id

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 01:30:37 +08:00

42 lines
962 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# LambdaTask::LambdaTask
```cpp
explicit LambdaTask(Func&& func, TaskPriority priority = TaskPriority::Normal)
```
构造 Lambda 任务对象,将可调用对象包装为 ITask。
**模板参数:**
- `Func` - 可调用对象类型
**参数:**
- `func` - 要封装的可调用对象lambda、函数指针、std::function 等)
- `priority` - 任务优先级,默认值为 TaskPriority::Normal
**返回:**
**复杂度:** O(1)
**示例:**
```cpp
// 使用 std::function lambda
auto task = std::make_unique<LambdaTask<std::function<void()>>>(
[]() { printf("Task executed\n"); },
TaskPriority::High
);
TaskSystem::Get().Submit(std::move(task));
// 配合 TaskSystem::Submit 的重载直接使用
TaskSystem::Get().Submit(
std::make_unique<LambdaTask<std::function<void()>>>(
[]() { ProcessData(); },
TaskPriority::Critical
)
);
```
## 相关文档
- [LambdaTask 总览](lambda-task.md) - 返回类总览