docs: update memory and threading API docs
This commit is contained in:
@@ -33,6 +33,8 @@ uint64_t Submit(std::function<void()>&& func, TaskPriority priority = TaskPriori
|
||||
|
||||
**复杂度:** O(log n)
|
||||
|
||||
**线程安全:** ✅ (内部使用 mutex 保护任务队列)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
@@ -52,10 +54,12 @@ uint64_t id3 = TaskSystem::Get().Submit([]() {
|
||||
HeavyCompute();
|
||||
}, TaskPriority::High);
|
||||
|
||||
// 等待任务完成
|
||||
TaskSystem::Get().Wait(id1);
|
||||
TaskSystem::Get().Wait(id2);
|
||||
TaskSystem::Get().Wait(id3);
|
||||
// 使用 TaskGroup 等待任务完成
|
||||
TaskGroup* group = TaskSystem::Get().CreateTaskGroup();
|
||||
group->AddTask([]() { /* task 1 */ });
|
||||
group->AddTask([]() { /* task 2 */ });
|
||||
group->Wait();
|
||||
TaskSystem::Get().DestroyTaskGroup(group);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
Reference in New Issue
Block a user