X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/167d8a885fcf184ce71bbeeb8afa610dd38508c9..e11898f903183f897a2b2a50a4447ea73ba7273f:/src/mac/carbon/mpthread.cpp diff --git a/src/mac/carbon/mpthread.cpp b/src/mac/carbon/mpthread.cpp index 52976e92a5..c3711fd1a3 100755 --- a/src/mac/carbon/mpthread.cpp +++ b/src/mac/carbon/mpthread.cpp @@ -35,17 +35,16 @@ #include "wx/thread.h" #ifdef __WXMAC__ +#if TARGET_API_MAC_OSX #include +#else +#include +#include +#include +#endif #include "wx/mac/uma.h" #endif -// trace mask for wxThread operations -#define TRACE_THREADS _T("thread") - -// you can get additional debugging messages for the semaphore operations -#define TRACE_SEMA _T("semaphore") - - // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -127,6 +126,20 @@ MPCriticalRegionID gs_guiCritical = kInvalidID; // wxMutex implementation // ---------------------------------------------------------------------------- +static bool wxMacMPThreadsInitVerify() +{ + static bool hasThreadManager = false ; + if ( !hasThreadManager ) + hasThreadManager = MPLibraryIsLoaded(); + + if ( !hasThreadManager ) + { + wxMessageBox( wxT("Error") , wxT("MP Thread Support is not available on this System" ), wxOK ) ; + return FALSE ; + } + return TRUE ; +} + #if 0 class wxMutexInternal @@ -146,6 +159,8 @@ private: wxMutexInternal::wxMutexInternal(wxMutexType mutexType ) { + wxMacMPThreadsInitVerify() ; + m_isOk = false ; m_semaphore = kInvalidID ; @@ -235,6 +250,7 @@ private: wxMutexInternal::wxMutexInternal(wxMutexType mutexType ) { + wxMacMPThreadsInitVerify() ; m_isOk = false ; m_critRegion = kInvalidID ; @@ -328,6 +344,7 @@ private: wxSemaphoreInternal::wxSemaphoreInternal(int initialcount, int maxcount) { + wxMacMPThreadsInitVerify() ; m_isOk = false ; m_semaphore = kInvalidID ; if ( maxcount == 0 ) @@ -779,7 +796,7 @@ private: MPQueueID m_notifyQueueId; // its notification queue 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; @@ -861,6 +878,7 @@ OSStatus wxThreadInternal::MacThreadStart(void *parameter) bool wxThreadInternal::Create(wxThread *thread, unsigned int stackSize) { + wxMacMPThreadsInitVerify() ; wxASSERT_MSG( m_state == STATE_NEW && !m_tid, _T("Create()ing thread twice?") ); @@ -909,8 +927,8 @@ void wxThreadInternal::SetPriority( int priority) if ( m_tid) { // Mac priorities range from 1 to 10,000, with a default of 100. - // wxWindows priorities range from 0 to 100 with a default of 50. - // We can map wxWindows to Mac priorities easily by assuming + // wxWidgets priorities range from 0 to 100 with a default of 50. + // We can map wxWidgets to Mac priorities easily by assuming // the former uses a logarithmic scale. const unsigned int macPriority = ( int)( exp( priority / 25.0 * log( 10.0)) + 0.5); @@ -1149,16 +1167,9 @@ wxThreadError wxThread::Resume() switch ( state ) { case STATE_PAUSED: - wxLogTrace(TRACE_THREADS, _T("Thread %ld suspended, resuming."), - GetId()); - m_internal->Resume(); - return wxTHREAD_NO_ERROR; - case STATE_EXITED: - wxLogTrace(TRACE_THREADS, _T("Thread %ld exited, won't resume."), - GetId()); return wxTHREAD_NO_ERROR; default: @@ -1422,13 +1433,9 @@ private: IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule) bool wxThreadModule::OnInit() -{ - bool hasThreadManager = false ; - hasThreadManager = MPLibraryIsLoaded(); - - if ( !hasThreadManager ) +{ + if ( !wxMacMPThreadsInitVerify() ) { - wxMessageBox( "Error" , "MP Thread Support is not available on this System" , wxOK ) ; return FALSE ; }