Added wxThread::GetMainId().

This is useful for checking if a message was logged from the main thread or not and also allows us to implement IsMain() by comparing GetCurrentId() with GetMainId() in all ports and avoid repetition.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61406 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-07-11 20:46:55 +00:00
parent 7dfede7b92
commit f922638305
6 changed files with 51 additions and 60 deletions

View File

@@ -57,7 +57,7 @@ enum wxThreadState
// id of the main thread - the one which can call GUI functions without first
// calling wxMutexGuiEnter()
static ULONG s_ulIdMainThread = 1;
wxThreadIdType wxThread::ms_idMainThread = 0;
wxMutex* p_wxMainMutex;
// OS2 substitute for Tls pointer the current parent thread object
@@ -547,19 +547,6 @@ wxThread *wxThread::This()
return pThread;
}
bool wxThread::IsMain()
{
PTIB ptib;
PPIB ppib;
::DosGetInfoBlocks(&ptib, &ppib);
if (ptib->tib_ptib2->tib2_ultid == s_ulIdMainThread)
return true;
return false;
}
#ifdef Yield
#undef Yield
#endif
@@ -582,13 +569,13 @@ int wxThread::GetCPUCount()
return CPUCount;
}
unsigned long wxThread::GetCurrentId()
wxThreadIdType wxThread::GetCurrentId()
{
PTIB ptib;
PPIB ppib;
::DosGetInfoBlocks(&ptib, &ppib);
return (unsigned long) ptib->tib_ptib2->tib2_ultid;
return (wxThreadIdType) ptib->tib_ptib2->tib2_ultid;
}
bool wxThread::SetConcurrency(size_t level)
@@ -937,12 +924,8 @@ bool wxThreadModule::OnInit()
gs_pCritsectGui = new wxCriticalSection();
gs_pCritsectGui->Enter();
PTIB ptib;
PPIB ppib;
wxThread::ms_idMainThread = wxThread::GetCurrentId();
::DosGetInfoBlocks(&ptib, &ppib);
s_ulIdMainThread = ptib->tib_ptib2->tib2_ultid;
return true;
}