static wxArrayThread gs_allThreads;
// the id of the main thread
-static pthread_t gs_tidMain;
+static pthread_t gs_tidMain = (pthread_t)-1;
// the key for the pointer to the associated wxThread object
static pthread_key_t gs_keySelf;
while ( m_count == 0 )
{
wxLogTrace(TRACE_SEMA,
- "Thread %ld waiting for semaphore to become signalled",
+ _T("Thread %ld waiting for semaphore to become signalled"),
wxThread::GetCurrentId());
if ( m_cond.Wait() != wxCOND_NO_ERROR )
return wxSEMA_MISC_ERROR;
wxLogTrace(TRACE_SEMA,
- "Thread %ld finished waiting for semaphore, count = %lu",
+ _T("Thread %ld finished waiting for semaphore, count = %lu"),
wxThread::GetCurrentId(), (unsigned long)m_count);
}
m_count++;
wxLogTrace(TRACE_SEMA,
- "Thread %ld about to signal semaphore, count = %lu",
+ _T("Thread %ld about to signal semaphore, count = %lu"),
wxThread::GetCurrentId(), (unsigned long)m_count);
return m_cond.Signal() == wxCOND_NO_ERROR ? wxSEMA_NO_ERROR
private:
pthread_t m_threadId; // id of the thread
wxThreadState m_state; // see wxThreadState enum
- int m_prio; // in wxWindows units: from 0 to 100
+ int m_prio; // in wxWidgets units: from 0 to 100
// this flag is set when the thread should terminate
bool m_cancelled;
// wxLogDebug: it is possible to bring the system to its knees
// by creating too many threads and not joining them quite
// easily
- wxLogError(_("Failed to join a thread, potential memory leak "
- "detected - please restart the program"));
+ wxLogError(_("Failed to join a thread, potential memory leak detected - please restart the program"));
}
m_shouldBeJoined = FALSE;
bool wxThread::IsMain()
{
- return (bool)pthread_equal(pthread_self(), gs_tidMain);
+ return (bool)pthread_equal(pthread_self(), gs_tidMain) || gs_tidMain == (pthread_t)-1;
}
void wxThread::Yield()
void wxThread::Sleep(unsigned long milliseconds)
{
- wxUsleep(milliseconds);
+ wxMilliSleep(milliseconds);
}
int wxThread::GetCPUCount()
void wxThread::Exit(ExitCode status)
{
wxASSERT_MSG( This() == this,
- _T("wxThread::Exit() can only be called in the "
- "context of the same thread") );
+ _T("wxThread::Exit() can only be called in the context of the same thread") );
if ( m_isDetached )
{
bool wxThread::TestDestroy()
{
wxASSERT_MSG( This() == this,
- _T("wxThread::TestDestroy() can only be called in the "
- "context of the same thread") );
+ _T("wxThread::TestDestroy() can only be called in the context of the same thread") );
m_critsect.Enter();
if ( m_internal->GetState() != STATE_EXITED &&
m_internal->GetState() != STATE_NEW )
{
- wxLogDebug(_T("The thread %ld is being destroyed although it is still "
- "running! The application may crash."), GetId());
+ wxLogDebug(_T("The thread %ld is being destroyed although it is still running! The application may crash."), GetId());
}
m_critsect.Leave();
int rc = pthread_key_create(&gs_keySelf, NULL /* dtor function */);
if ( rc != 0 )
{
- wxLogSysError(rc, _("Thread module initialization failed: "
- "failed to create thread key"));
+ wxLogSysError(rc, _("Thread module initialization failed: failed to create thread key"));
return FALSE;
}