graphics: cache the macOS thread id in TrackingSpinLock (#1169)

Every lock and unlock called pthread_mach_thread_np. Cache it per thread like the Linux branch does.
This commit is contained in:
Romain Hedouin
2026-10-08 01:18:49 +02:00
committed by GitHub
parent 420bb51d6c
commit 79a91ecfaf
+3 -1
View File
@@ -60,7 +60,9 @@ private:
return GetCurrentThreadId();
#elif defined(__APPLE__)
// mach thread port is a nonzero per-thread id (0 is the "no owner" sentinel).
return static_cast<uint32_t>(pthread_mach_thread_np(pthread_self()));
static thread_local const uint32_t tid =
static_cast<uint32_t>(pthread_mach_thread_np(pthread_self()));
return tid;
#elif defined(__linux__)
static thread_local const uint32_t tid = static_cast<uint32_t>(::syscall(SYS_gettid));
return tid;