Fix 14 broken cross-references in docs/api/threading/: - lambda-task path: lambdatask -> lambda-task (5 occurrences) - task-system-config path: tasksystemconfig -> task-system-config (6 occurrences) - read-write-lock self-ref: readwritelock -> read-write-lock (6 occurrences) - task-system cross-method: createtaskgroup/destroytaskgroup -> create-task-group/destroy-task-group - thread cross-method: getcurrentid/getid -> get-current-id/get-id Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1.1 KiB
1.1 KiB
Thread::GetCurrentId
static Id GetCurrentId();
静态方法,返回当前执行线程的唯一标识符。此方法可在任意线程上下文中调用,包括主线程和工作线程。
线程 ID 通过 std::this_thread::get_id() 获取,并使用 std::hash<std::thread::id> 转换为 uint64_t 值。该值与 Thread::GetId() 返回的值格式一致,可以直接比较。
参数: 无
返回: 调用线程的唯一标识符
线程安全: ✅
示例:
#include "XCEngine/Threading/Thread.h"
#include <iostream>
using namespace XCEngine::Threading;
int main() {
std::cout << "Main thread ID: " << Thread::GetCurrentId() << std::endl;
Thread t;
t.Start([]() {
std::cout << "Worker thread ID: " << Thread::GetCurrentId() << std::endl;
std::cout << "Worker ID matches Thread.GetId(): "
<< (Thread::GetCurrentId() == t.GetId() ? "Yes" : "No") << std::endl;
}, "CheckIdThread");
t.Join();
return 0;
}