From a14339dbd418789ad0232f42391c4890ab95845f Mon Sep 17 00:00:00 2001 From: DH Date: Wed, 9 Apr 2025 06:09:02 +0300 Subject: [PATCH] thread/named_thread_group: pass thread id if worker accepts it --- rpcs3/util/Thread.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rpcs3/util/Thread.h b/rpcs3/util/Thread.h index 258bffcd3..3f2bc031a 100644 --- a/rpcs3/util/Thread.h +++ b/rpcs3/util/Thread.h @@ -771,10 +771,20 @@ public: { // Copy the context new (static_cast(m_threads + i)) Thread(std::string(name) + std::to_string(i + 1), static_cast(f)); + + if constexpr (requires { f(i); }) + { + m_threads[i](i); + } } // Move the context (if movable) new (static_cast(m_threads + m_count - 1)) Thread(std::string(name) + std::to_string(m_count), std::forward(f)); + + if constexpr (requires { f(m_count - 1); }) + { + m_threads[m_count - 1](m_count - 1); + } } // Constructor with a function performed before adding more threads