#define THR_ID(thr) ((long)(thr)->GetId())
#endif
-#ifdef __WXMAC__
-
- // implement wxCriticalSection using mutexes
-wxCriticalSection::wxCriticalSection( wxCriticalSectionType critSecType )
- : m_mutex( critSecType == wxCRITSEC_DEFAULT ? wxMUTEX_RECURSIVE : wxMUTEX_DEFAULT ) { }
-wxCriticalSection::~wxCriticalSection() { }
-
-void wxCriticalSection::Enter() { (void)m_mutex.Lock(); }
-void wxCriticalSection::Leave() { (void)m_mutex.Unlock(); }
-
-#endif
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
static size_t gs_nThreadsBeingDeleted = 0;
// a mutex to protect gs_nThreadsBeingDeleted
-static wxMutex *gs_mutexDeleteThread = (wxMutex *)NULL;
+static wxMutex *gs_mutexDeleteThread = NULL;
// and a condition variable which will be signaled when all
// gs_nThreadsBeingDeleted will have been deleted
-static wxCondition *gs_condAllDeleted = (wxCondition *)NULL;
+static wxCondition *gs_condAllDeleted = NULL;
// this mutex must be acquired before any call to a GUI function
// (it's not inside #if wxUSE_GUI because this file is compiled as part
if (m_owningThread == wxThread::GetCurrentId())
return wxMUTEX_DEAD_LOCK;
}
-
+
return HandleLockResult(pthread_mutex_lock(&m_mutex));
}
wxMutexError wxMutexInternal::Unlock()
{
m_owningThread = 0;
-
+
int err = pthread_mutex_unlock(&m_mutex);
switch ( err )
{
while ( m_count == 0 )
{
wxLogTrace(TRACE_SEMA,
- _T("Thread %ld waiting for semaphore to become signalled"),
+ _T("Thread %p waiting for semaphore to become signalled"),
wxThread::GetCurrentId());
if ( m_cond.Wait() != wxCOND_NO_ERROR )
return wxSEMA_MISC_ERROR;
wxLogTrace(TRACE_SEMA,
- _T("Thread %ld finished waiting for semaphore, count = %lu"),
+ _T("Thread %p finished waiting for semaphore, count = %lu"),
wxThread::GetCurrentId(), (unsigned long)m_count);
}
m_count++;
wxLogTrace(TRACE_SEMA,
- _T("Thread %ld about to signal semaphore, count = %lu"),
+ _T("Thread %p about to signal semaphore, count = %lu"),
wxThread::GetCurrentId(), (unsigned long)m_count);
return m_cond.Signal() == wxCOND_NO_ERROR ? wxSEMA_NO_ERROR
_T("EXITED"),
};
- wxLogTrace(TRACE_THREADS, _T("Thread %ld: %s => %s."),
- (long)GetId(), stateNames[m_state], stateNames[state]);
+ wxLogTrace(TRACE_THREADS, _T("Thread %p: %s => %s."),
+ GetId(), stateNames[m_state], stateNames[state]);
#endif // __WXDEBUG__
m_state = state;
{
wxThreadInternal *pthread = thread->m_internal;
- wxLogTrace(TRACE_THREADS, _T("Thread %ld started."), THR_ID(pthread));
+ wxLogTrace(TRACE_THREADS, _T("Thread %p started."), THR_ID(pthread));
// associate the thread pointer with the newly created thread so that
// wxThread::This() will work
{
// call the main entry
wxLogTrace(TRACE_THREADS,
- _T("Thread %ld about to enter its Entry()."),
+ _T("Thread %p about to enter its Entry()."),
THR_ID(pthread));
wxTRY
pthread->m_exitcode = thread->Entry();
wxLogTrace(TRACE_THREADS,
- _T("Thread %ld Entry() returned %lu."),
+ _T("Thread %p Entry() returned %lu."),
THR_ID(pthread), wxPtrToUInt(pthread->m_exitcode));
}
wxCATCH_ALL( wxTheApp->OnUnhandledException(); )
wxMutexGuiLeave();
wxLogTrace(TRACE_THREADS,
- _T("Starting to wait for thread %ld to exit."),
+ _T("Starting to wait for thread %p to exit."),
THR_ID(this));
// to avoid memory leaks we should call pthread_join(), but it must only be
wxT("thread must first be paused with wxThread::Pause().") );
wxLogTrace(TRACE_THREADS,
- _T("Thread %ld goes to sleep."), THR_ID(this));
+ _T("Thread %p goes to sleep."), THR_ID(this));
// wait until the semaphore is Post()ed from Resume()
m_semSuspend.Wait();
if ( IsReallyPaused() )
{
wxLogTrace(TRACE_THREADS,
- _T("Waking up thread %ld"), THR_ID(this));
+ _T("Waking up thread %p"), THR_ID(this));
// wake up Pause()
m_semSuspend.Post();
else
{
wxLogTrace(TRACE_THREADS,
- _T("Thread %ld is not yet really paused"), THR_ID(this));
+ _T("Thread %p is not yet really paused"), THR_ID(this));
}
SetState(STATE_RUNNING);
switch ( state )
{
case STATE_PAUSED:
- wxLogTrace(TRACE_THREADS, _T("Thread %ld suspended, resuming."),
+ wxLogTrace(TRACE_THREADS, _T("Thread %p suspended, resuming."),
GetId());
m_internal->Resume();
return wxTHREAD_NO_ERROR;
case STATE_EXITED:
- wxLogTrace(TRACE_THREADS, _T("Thread %ld exited, won't resume."),
+ wxLogTrace(TRACE_THREADS, _T("Thread %p exited, won't resume."),
GetId());
return wxTHREAD_NO_ERROR;
// or wxThreadModule::OnExit() would deadlock
wxMutexLocker locker( *gs_mutexDeleteThread );
- wxLogTrace(TRACE_THREADS, _T("Thread %ld auto deletes."), This->GetId());
+ wxLogTrace(TRACE_THREADS, _T("Thread %p auto deletes."), This->GetId());
delete This;
wxCHECK_RET( gs_nThreadsBeingDeleted > 0,
_T("no threads scheduled for deletion, yet we delete one?") );
- wxLogTrace(TRACE_THREADS, _T("%lu scheduled for deletion threads left."),
+ wxLogTrace(TRACE_THREADS, _T("%lu threads remain scheduled for deletion."),
(unsigned long)gs_nThreadsBeingDeleted - 1);
if ( !--gs_nThreadsBeingDeleted )