Replace SMXHelperThread::GetThreadId() with SMXHelperThread::IsCurrentThread().

This commit is contained in:
Glenn Maynard 2018-11-05 17:58:31 -06:00
parent ad2e7dcb74
commit a7cb6ad51d
3 changed files with 8 additions and 4 deletions

View File

@ -74,3 +74,8 @@ void SMX::SMXHelperThread::RunInThread(function<void()> func)
SetEvent(m_hEvent->value()); SetEvent(m_hEvent->value());
m_Lock.Unlock(); m_Lock.Unlock();
} }
bool SMX::SMXHelperThread::IsCurrentThread() const
{
return GetCurrentThreadId() == m_iThreadId;
}

View File

@ -26,9 +26,8 @@ public:
// Call func asynchronously from the helper thread. // Call func asynchronously from the helper thread.
void RunInThread(function<void()> func); void RunInThread(function<void()> func);
// Return the Win32 thread ID, or INVALID_HANDLE_VALUE if the thread has been // Return true if this is the calling thread.
// shut down. bool IsCurrentThread() const;
DWORD GetThreadId() const { return m_iThreadId; }
private: private:
static DWORD WINAPI ThreadMainStart(void *self_); static DWORD WINAPI ThreadMainStart(void *self_);

View File

@ -71,7 +71,7 @@ void SMX::SMXManager::Shutdown()
// Make sure we're not being called from within m_UserCallbackThread, since that'll // Make sure we're not being called from within m_UserCallbackThread, since that'll
// deadlock when we shut down m_UserCallbackThread. // deadlock when we shut down m_UserCallbackThread.
if(m_UserCallbackThread.GetThreadId() == GetCurrentThreadId()) if(m_UserCallbackThread.IsCurrentThread())
throw runtime_error("SMX::SMXManager::Shutdown must not be called from an SMX callback"); throw runtime_error("SMX::SMXManager::Shutdown must not be called from an SMX callback");
// Shut down the thread we make user callbacks from. // Shut down the thread we make user callbacks from.