docs: update resources API docs
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
**类型**: `class` (singleton)
|
||||
|
||||
**头文件**: `XCEngine/Resources/AsyncLoader.h`
|
||||
|
||||
**描述**: 异步资源加载器单例,负责多线程后台资源加载和完成回调调度。
|
||||
|
||||
## 概述
|
||||
@@ -59,13 +61,25 @@
|
||||
| `void CancelAll()` | 取消所有待处理的加载请求 |
|
||||
| `void Cancel(Core::uint64 requestId)` | 取消指定 ID 的加载请求 |
|
||||
|
||||
### 方法详情
|
||||
|
||||
- [Initialize](initialize.md) - 初始化异步加载器
|
||||
- [Shutdown](shutdown.md) - 关闭异步加载器
|
||||
- [Submit](submit.md) - 提交异步加载请求
|
||||
- [Update](update.md) - 更新函数,处理完成的加载请求
|
||||
- [IsLoading](isloading.md) - 检查是否有正在加载的资源
|
||||
- [GetPendingCount](getpendingcount.md) - 获取待处理加载请求数量
|
||||
- [GetProgress](getprogress.md) - 获取整体加载进度
|
||||
- [CancelAll](cancelall.md) - 取消所有待处理的加载请求
|
||||
- [Cancel](cancel.md) - 取消指定 ID 的加载请求
|
||||
|
||||
## 实现说明
|
||||
|
||||
**注意**: 当前 `AsyncLoader` 的实现为部分完成状态(stub):
|
||||
- `Initialize()` 工作线程数参数被忽略
|
||||
- `Submit()` 仅将请求加入队列,不进行实际异步加载
|
||||
- `Update()` 不执行实际加载,直接调用回调返回成功
|
||||
- `QueueCompleted()` 和 `Cancel()` 为空实现
|
||||
- `Cancel()` 为空实现
|
||||
|
||||
## 使用示例
|
||||
|
||||
|
||||
27
docs/api/resources/asyncloader/cancel.md
Normal file
27
docs/api/resources/asyncloader/cancel.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# AsyncLoader::Cancel
|
||||
|
||||
```cpp
|
||||
void Cancel(Core::uint64 requestId)
|
||||
```
|
||||
|
||||
取消指定 ID 的加载请求。
|
||||
|
||||
**参数:**
|
||||
- `requestId` - 要取消的请求 ID(由 `LoadRequest::requestId` 提供)
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**注意:** 当前实现未完成此功能。
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
LoadRequest req("textures/player.png", ResourceType::Texture,
|
||||
[](LoadResult result) { /* ... */ });
|
||||
|
||||
AsyncLoader::Get().Cancel(req.requestId);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [AsyncLoader 总览](asyncloader.md) - 返回类总览
|
||||
24
docs/api/resources/asyncloader/getpendingcount.md
Normal file
24
docs/api/resources/asyncloader/getpendingcount.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# AsyncLoader::GetPendingCount
|
||||
|
||||
```cpp
|
||||
Core::uint32 GetPendingCount() const
|
||||
```
|
||||
|
||||
获取当前待处理的加载请求数量。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 待处理加载请求数量
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Core::uint32 pending = AsyncLoader::Get().GetPendingCount();
|
||||
printf("Pending requests: %u\n", pending);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [AsyncLoader 总览](asyncloader.md) - 返回类总览
|
||||
24
docs/api/resources/asyncloader/initialize.md
Normal file
24
docs/api/resources/asyncloader/initialize.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# AsyncLoader::Initialize
|
||||
|
||||
```cpp
|
||||
void Initialize(Core::uint32 workerThreadCount = 2)
|
||||
```
|
||||
|
||||
初始化异步加载器。根据 `workerThreadCount` 参数创建相应数量的工作线程用于后台资源加载。
|
||||
|
||||
**参数:**
|
||||
- `workerThreadCount` - 工作线程数量,默认为 2
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**复杂度:** O(n),n 为创建的工作线程数
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
AsyncLoader::Get().Initialize(4);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [AsyncLoader 总览](asyncloader.md) - 返回类总览
|
||||
25
docs/api/resources/asyncloader/isloading.md
Normal file
25
docs/api/resources/asyncloader/isloading.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# AsyncLoader::IsLoading
|
||||
|
||||
```cpp
|
||||
bool IsLoading() const
|
||||
```
|
||||
|
||||
检查是否有正在加载的资源。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 如果有待处理或完成的加载请求返回 `true`,否则返回 `false`
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
if (AsyncLoader::Get().IsLoading()) {
|
||||
printf("Resources are still loading...\n");
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [AsyncLoader 总览](asyncloader.md) - 返回类总览
|
||||
23
docs/api/resources/asyncloader/shutdown.md
Normal file
23
docs/api/resources/asyncloader/shutdown.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# AsyncLoader::Shutdown
|
||||
|
||||
```cpp
|
||||
void Shutdown()
|
||||
```
|
||||
|
||||
关闭异步加载器。取消所有待处理的加载请求并清理资源。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**复杂度:** O(n)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
AsyncLoader::Get().Shutdown();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [AsyncLoader 总览](asyncloader.md) - 返回类总览
|
||||
@@ -33,3 +33,4 @@ AsyncLoader::Get().Submit("textures/player.png", ResourceType::Texture,
|
||||
## 相关文档
|
||||
|
||||
- [AsyncLoader 总览](asyncloader.md) - 返回类总览
|
||||
- [Cancel](cancel.md) - 取消指定请求
|
||||
|
||||
Reference in New Issue
Block a user