From 79a91ecfafea899e25dc0df0df6ffb55a8f3cc58 Mon Sep 17 00:00:00 2001 From: Romain Hedouin Date: Thu, 8 Oct 2026 01:18:49 +0200 Subject: [PATCH] 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. --- src/graphics/host_gpu/regionManager.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/graphics/host_gpu/regionManager.h b/src/graphics/host_gpu/regionManager.h index 9fae4ef7a..bcb05bb62 100644 --- a/src/graphics/host_gpu/regionManager.h +++ b/src/graphics/host_gpu/regionManager.h @@ -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(pthread_mach_thread_np(pthread_self())); + static thread_local const uint32_t tid = + static_cast(pthread_mach_thread_np(pthread_self())); + return tid; #elif defined(__linux__) static thread_local const uint32_t tid = static_cast(::syscall(SYS_gettid)); return tid;