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/writelock.md
Normal file
41
docs/api/threading/read-write-lock/writelock.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# ReadWriteLock::WriteLock
|
||||
|
||||
```cpp
|
||||
void WriteLock()
|
||||
```
|
||||
|
||||
获取写锁(独占)。如果有读者持有锁或有其他写者正在等待,当前线程将阻塞,直到获得独占访问权。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**复杂度:** 平均 O(1),写者饥饿时可能 O(n)
|
||||
|
||||
**注意:**
|
||||
- 写锁为独占访问,持有期间不允许任何读锁或写锁。
|
||||
- 写锁具有优先权,会阻塞后续到达的读者。
|
||||
- 同一线程不可重复 WriteLock。
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/Threading/ReadWriteLock.h"
|
||||
#include <vector>
|
||||
|
||||
XCEngine::Threading::ReadWriteLock rwLock;
|
||||
std::vector<int> buffer;
|
||||
|
||||
void Append(int value) {
|
||||
rwLock.WriteLock();
|
||||
buffer.push_back(value);
|
||||
rwLock.WriteUnlock();
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [`ReadWriteLock`](readwritelock.md) - 返回类总览
|
||||
- [`WriteUnlock`](writeunlock.md) - 释放写锁
|
||||
Reference in New Issue
Block a user