X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d9d14984ff9f41ab86d01f0db28b50e4ae9774d6..0d1c8f39baaaeb7a7f757091209eab471ef5dbc4:/src/mac/carbon/mpthread.cpp diff --git a/src/mac/carbon/mpthread.cpp b/src/mac/carbon/mpthread.cpp index b0d67a020c..9da62d0185 100755 --- a/src/mac/carbon/mpthread.cpp +++ b/src/mac/carbon/mpthread.cpp @@ -10,10 +10,6 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "thread.h" -#endif - // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- @@ -40,7 +36,7 @@ #else #include #include -#include +#include "wx/math.h" #endif #include "wx/mac/uma.h" #endif @@ -126,6 +122,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 @@ -145,6 +155,8 @@ private: wxMutexInternal::wxMutexInternal(wxMutexType mutexType ) { + wxMacMPThreadsInitVerify() ; + m_isOk = false ; m_semaphore = kInvalidID ; @@ -234,6 +246,7 @@ private: wxMutexInternal::wxMutexInternal(wxMutexType mutexType ) { + wxMacMPThreadsInitVerify() ; m_isOk = false ; m_critRegion = kInvalidID ; @@ -327,6 +340,7 @@ private: wxSemaphoreInternal::wxSemaphoreInternal(int initialcount, int maxcount) { + wxMacMPThreadsInitVerify() ; m_isOk = false ; m_semaphore = kInvalidID ; if ( maxcount == 0 ) @@ -778,7 +792,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; @@ -860,6 +874,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?") ); @@ -908,8 +923,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); @@ -955,7 +970,7 @@ void wxThreadInternal::Wait() kDurationForever); if ( err) { - wxLogSysError( _( "Cannot wait on thread to exit.")); + wxLogSysError( _( "Cannot wait for thread termination.")); rc = (void*) -1; } @@ -1414,13 +1429,9 @@ private: IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule) bool wxThreadModule::OnInit() -{ - bool hasThreadManager = false ; - hasThreadManager = MPLibraryIsLoaded(); - - if ( !hasThreadManager ) +{ + if ( !wxMacMPThreadsInitVerify() ) { - wxMessageBox( wxT("Error") , wxT("MP Thread Support is not available on this System" ), wxOK ) ; return FALSE ; }