docs: update core and debug API docs

This commit is contained in:
2026-03-20 02:35:07 +08:00
parent 0c073db4e8
commit e165dbea1c
73 changed files with 743 additions and 391 deletions

View File

@@ -4,34 +4,40 @@
void AddRef();
```
增加引用计数。
原子地增加引用计数。
**描述**
原子地增加引用计数。在复制 `RefCounted` 指针或传递引用时调用此方法。
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
#include <XCEngine/Core/RefCounted.h>
#include <cstdio>
class MyObject : public RefCounted {
class MyObject : public XCEngine::Core::RefCounted {
public:
void DoSomething() { /* ... */ }
void DoSomething() { }
};
// 创建对象(构造时 refCount = 1
MyObject* obj = new MyObject();
// 手动增加引用
obj->AddRef(); // refCount = 2
obj->AddRef(); // refCount = 3
// 需要释放额外的引用
obj->Release(); // refCount = 2
obj->Release(); // refCount = 1
int main() {
MyObject* obj = new MyObject();
printf("After create: %u\n", obj->GetRefCount());
obj->AddRef();
printf("After AddRef: %u\n", obj->GetRefCount());
obj->Release();
printf("After Release: %u\n", obj->GetRefCount());
obj->Release();
return 0;
}
```
## 相关文档