docs: update core and debug API docs
This commit is contained in:
@@ -12,28 +12,36 @@ uint32_t GetRefCount() const;
|
||||
|
||||
**返回:** `uint32_t` - 当前引用计数
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Core/RefCounted.h>
|
||||
#include <cstdio>
|
||||
|
||||
class MyObject : public RefCounted {
|
||||
class MyObject : public XCEngine::Core::RefCounted {
|
||||
public:
|
||||
void Debug() {
|
||||
printf("RefCount: %u\n", GetRefCount());
|
||||
}
|
||||
};
|
||||
|
||||
MyObject* obj = new MyObject();
|
||||
printf("After create: %u\n", obj->GetRefCount()); // 1
|
||||
|
||||
obj->AddRef();
|
||||
printf("After AddRef: %u\n", obj->GetRefCount()); // 2
|
||||
|
||||
obj->Release();
|
||||
printf("After Release: %u\n", obj->GetRefCount()); // 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;
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
Reference in New Issue
Block a user