diff --git a/include/support/SafeThread.h b/include/support/SafeThread.h index 465957be3d..0f39bc6811 100644 --- a/include/support/SafeThread.h +++ b/include/support/SafeThread.h @@ -82,9 +82,13 @@ class SafeThreadOwnerBase { protected: void Start(SafeThread* thr); SafeThread* GetThread() const { return m_thread.load(); } + std::thread::native_handle_type GetNativeThreadHandle() const { + return m_nativeHandle; + } private: std::atomic m_thread; + std::atomic m_nativeHandle; }; inline void SafeThreadOwnerBase::Start(SafeThread* thr) { @@ -94,10 +98,12 @@ inline void SafeThreadOwnerBase::Start(SafeThread* thr) { delete newthr; return; } - std::thread([=]() { + std::thread stdThread([=]() { newthr->Main(); delete newthr; - }).detach(); + }); + m_nativeHandle = stdThread.native_handle(); + stdThread.detach(); } inline void SafeThreadOwnerBase::Stop() {