refactor: improve test infrastructure and fix OpenGL GLAD initialization
- Rename D3D12Enum.h to D3D12Enums.h for naming consistency - Fix OpenGL unit test GLAD initialization by using gladLoadGL() instead of gladLoadGLLoader(wglGetProcAddress) for fallback support - Migrate remaining tests to use gtest_discover_tests for granular test discovery (math, core, containers, memory, threading, debug, components, scene, resources, input, opengl) - Remove obsolete TEST_RESOURCES_DIR and copy_directory commands from OpenGL unit test CMakeLists (minimal/Res doesn't exist) - Update TEST_SPEC.md with performance metrics and per-module build/test commands for faster development workflow - Update CMake path references to use lowercase paths
This commit is contained in:
41
docs/api/threading/read-write-lock/readlock.md
Normal file
41
docs/api/threading/read-write-lock/readlock.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# ReadWriteLock::ReadLock
|
||||
|
||||
```cpp
|
||||
void ReadLock()
|
||||
```
|
||||
|
||||
获取读锁。如果有写者持有锁或正在等待写锁,当前线程将阻塞,直到所有写者完成。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** 平均 O(1)
|
||||
|
||||
**注意:**
|
||||
- 多个读者可以同时持有读锁。
|
||||
- 写锁具有优先权——正在等待的写者会阻塞新的读者,防止写者饥饿。
|
||||
- 读锁不可重入,同一线程不可嵌套持有读锁。
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Threading/ReadWriteLock.h"
|
||||
|
||||
XCEngine::Threading::ReadWriteLock rwLock;
|
||||
int sharedValue = 0;
|
||||
|
||||
int ReadValue() {
|
||||
rwLock.ReadLock();
|
||||
int value = sharedValue;
|
||||
rwLock.ReadUnlock();
|
||||
return value;
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [`ReadWriteLock`](readwritelock.md) - 返回类总览
|
||||
- [`ReadUnlock`](readunlock.md) - 释放读锁
|
||||
Reference in New Issue
Block a user