// 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
if (m_vMutex)
{
if (::DosCloseMutexSem(m_vMutex))
- wxLogLastError(_T("DosCloseMutexSem(mutex)"));
+ {
+ wxLogLastError(wxT("DosCloseMutexSem(mutex)"));
+ }
}
}
ulrc = ::DosCreateMutexSem(NULL, &m_vMutex, 0L, FALSE);
if (ulrc != 0)
{
- wxLogLastError(_T("DosCreateMutexSem()"));
+ wxLogLastError(wxT("DosCreateMutexSem()"));
m_vMutex = NULL;
m_vEvent = NULL;
return;
ulrc = ::DosCreateEventSem(NULL, &m_vEvent, 0L, FALSE);
if ( ulrc != 0)
{
- wxLogLastError(_T("DosCreateEventSem()"));
+ wxLogLastError(wxT("DosCreateEventSem()"));
::DosCloseMutexSem(m_vMutex);
m_vMutex = NULL;
m_vEvent = NULL;
{
if ( ::DosCloseEventSem(m_vEvent) )
{
- wxLogLastError(_T("DosCloseEventSem(semaphore)"));
+ wxLogLastError(wxT("DosCloseEventSem(semaphore)"));
}
if ( ::DosCloseMutexSem(m_vMutex) )
{
- wxLogLastError(_T("DosCloseMutexSem(semaphore)"));
+ wxLogLastError(wxT("DosCloseMutexSem(semaphore)"));
}
else
m_vEvent = NULL;
return wxSEMA_TIMEOUT;
default:
- wxLogLastError(_T("DosWaitEventSem(semaphore)"));
+ wxLogLastError(wxT("DosWaitEventSem(semaphore)"));
return wxSEMA_MISC_ERROR;
}
ulrc = :: DosRequestMutexSem(m_vMutex, ulMilliseconds);
return wxSEMA_OVERFLOW;
if ( ulrc != NO_ERROR && ulrc != ERROR_ALREADY_POSTED )
{
- wxLogLastError(_T("DosPostEventSem(semaphore)"));
+ wxLogLastError(wxT("DosPostEventSem(semaphore)"));
return wxSEMA_MISC_ERROR;
}
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
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)
{
- wxASSERT_MSG( IsMain(), _T("should only be called from the main thread") );
+ wxASSERT_MSG( IsMain(), wxT("should only be called from the main thread") );
// ok only for the default one
if ( level == 0 )
// although under Windows we can wait for any thread, it's an error to
// wait for a detached one in wxWin API
wxCHECK_MSG( !IsDetached(), (ExitCode)-1,
- _T("can't wait for detached thread") );
+ wxT("can't wait for detached thread") );
ExitCode rc = (ExitCode)-1;
(void)Delete(&rc);
return(rc);
gs_pCritsectGui = new wxCriticalSection();
gs_pCritsectGui->Enter();
- PTIB ptib;
- PPIB ppib;
-
- ::DosGetInfoBlocks(&ptib, &ppib);
+ wxThread::ms_idMainThread = wxThread::GetCurrentId();
- s_ulIdMainThread = ptib->tib_ptib2->tib2_ultid;
return true;
}