docs: fix threading module documentation discrepancies
- Fix include paths: use #include "Threading/..." instead of <XCEngine/Threading/...> - Document protected ITask constructors (ITask(), ITask(TaskPriority)) - Document Callback typedef in TaskGroup - Clarify Mutex STL-compatible methods are const - Note GetProgress() implementation limitation (returns 0.0f)
This commit is contained in:
@@ -71,13 +71,13 @@
|
||||
#include <XCEngine/Containers/Array.h>
|
||||
|
||||
// 基本用法
|
||||
Containers::Array<int> arr;
|
||||
XCEngine::Containers::Array<int> arr;
|
||||
arr.PushBack(1);
|
||||
arr.PushBack(2);
|
||||
arr.PushBack(3);
|
||||
|
||||
// 使用 initializer_list
|
||||
Containers::Array<int> arr2 = {1, 2, 3, 4, 5};
|
||||
XCEngine::Containers::Array<int> arr2 = {1, 2, 3, 4, 5};
|
||||
|
||||
// 迭代
|
||||
for (auto& elem : arr) {
|
||||
|
||||
@@ -30,21 +30,23 @@ Containers 模块提供了图形引擎常用的数据结构,包括动态数组
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Containers/Containers.h>
|
||||
#include <XCEngine/Containers/Array.h>
|
||||
#include <XCEngine/Containers/String.h>
|
||||
#include <XCEngine/Containers/HashMap.h>
|
||||
|
||||
// 使用 Array
|
||||
Containers::Array<int> arr;
|
||||
XCEngine::Containers::Array<int> arr;
|
||||
arr.PushBack(1);
|
||||
arr.PushBack(2);
|
||||
arr.PushBack(3);
|
||||
|
||||
// 使用 String
|
||||
Containers::String str;
|
||||
XCEngine::Containers::String str;
|
||||
str = "Hello, ";
|
||||
str += "World!";
|
||||
|
||||
// 使用 HashMap
|
||||
Containers::HashMap<Containers::String, int> map;
|
||||
XCEngine::Containers::HashMap<XCEngine::Containers::String, int> map;
|
||||
map.Insert("key1", 100);
|
||||
map.Insert("key2", 200);
|
||||
int* value = map.Find("key1");
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# String::Length / Capacity / Empty
|
||||
# String::Length / Size / Capacity / Empty
|
||||
|
||||
```cpp
|
||||
SizeType Length() const;
|
||||
SizeType Size() const;
|
||||
SizeType Capacity() const;
|
||||
bool Empty() const;
|
||||
```
|
||||
@@ -12,6 +13,7 @@ bool Empty() const;
|
||||
|
||||
**返回:**
|
||||
- `Length()` - 返回字符串的字符数(不包括终止 null 字符)
|
||||
- `Size()` - 与 `Length()` 功能相同,返回字符串的字符数
|
||||
- `Capacity()` - 返回已分配的存储容量
|
||||
- `Empty()` - 如果字符串为空则返回 `true`
|
||||
|
||||
@@ -28,6 +30,7 @@ int main() {
|
||||
|
||||
XCEngine::Containers::String s2("Hello");
|
||||
std::cout << "Length: " << s2.Length() << std::endl; // 输出: Length: 5
|
||||
std::cout << "Size: " << s2.Size() << std::endl; // 输出: Size: 5
|
||||
std::cout << "Capacity: " << s2.Capacity() << std::endl; // 输出: Capacity: 6 或更大
|
||||
|
||||
s2.Reserve(100);
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| [CStr](cstr.md) | 获取 C 字符串指针 |
|
||||
| [Length/Capacity/Empty](size.md) | 获取尺寸信息 |
|
||||
| [Length/Size/Capacity/Empty](size.md) | 获取尺寸信息 |
|
||||
| [operator[]](./operator-subscript.md) | 下标访问 |
|
||||
|
||||
### 容量管理
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
String Trim() const;
|
||||
```
|
||||
|
||||
移除字符串两端的空白字符(包括空格、制表符、换行符等 isspace 识别的字符),返回一个新的 String 对象,原字符串不变。
|
||||
移除字符串两端的空白字符(空格、制表符、换行符、回车符),返回一个新的 String 对象,原字符串不变。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
@@ -24,7 +24,7 @@ int main() {
|
||||
std::cout << "\"" << trimmed.CStr() << "\"" << std::endl; // 输出: "Hello World"
|
||||
|
||||
XCEngine::Containers::String s2("\t\n test \t\n");
|
||||
std::cout << "\"" << s2.Trim().CStr() << "\"" << std::endl; // 输出: "test"
|
||||
std::cout << "\"" << s2.Trim().CStr() << "\"" << std::endl; // 输出: "test" (空格、制表符、换行、回车被移除)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
## STL 兼容方法
|
||||
|
||||
支持 `lock()`, `unlock()`, `try_lock()` 以兼容 STL 的 lockable 概念(**注意**:这些方法为 const 成员函数)。
|
||||
支持 `lock()`, `unlock()`, `try_lock()` 以兼容 STL 的 lockable 概念。**注意**:这些方法为 `const` 成员函数。
|
||||
|
||||
## 使用示例
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ float GetProgress() const
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**注意:** 当前实现中 `m_completedCount` 未被更新,此方法始终返回 0.0f(任务组为空时返回 1.0f)。此为实现限制。
|
||||
**注意:** 当前实现中 `m_completedCount` 未被更新,此方法始终返回 0.0f(任务组为空时返回 1.0f)。此为实现限制,文档仅作记录。
|
||||
|
||||
**示例:**
|
||||
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
|
||||
`TaskGroup` 提供了一种批量管理任务的机制。它允许添加多个任务、设置任务依赖关系、等待所有任务完成,并提供进度回调功能。
|
||||
|
||||
## 公共类型
|
||||
|
||||
| 类型 | 描述 |
|
||||
|------|------|
|
||||
| `Callback = std::function<void()>` | 任务组回调函数类型 |
|
||||
|
||||
## 公共方法
|
||||
|
||||
### 构造/析构
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `ITask()` | 默认构造函数(受保护) |
|
||||
| `ITask(TaskPriority priority)` | 带优先级的构造函数(受保护) |
|
||||
| [`Execute`](execute.md) | 任务执行逻辑(纯虚) |
|
||||
| [`OnComplete`](oncomplete.md) | 任务完成回调(可重写) |
|
||||
| [`OnCancel`](oncancel.md) | 任务取消回调(可重写) |
|
||||
|
||||
@@ -20,7 +20,7 @@ void Start(Func&& func, const Containers::String& name = "Thread")
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Threading/Thread.h>
|
||||
#include "Threading/Thread.h"
|
||||
|
||||
Thread worker;
|
||||
worker.Start([]() {
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Threading/Thread.h>
|
||||
#include "Threading/Thread.h"
|
||||
|
||||
// 创建并启动线程
|
||||
Thread thread;
|
||||
|
||||
@@ -47,7 +47,7 @@ Threading 模块提供了一套完整的多线程编程工具,包括线程封
|
||||
## 任务系统使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Threading/TaskSystem.h>
|
||||
#include "Threading/TaskSystem.h"
|
||||
|
||||
// 初始化任务系统
|
||||
TaskSystemConfig config;
|
||||
|
||||
Reference in New Issue
Block a user