X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/02761f6cd478e3c2c97cf6f93442747f7b029833..4eccf53dd554235876dccd4e37331d64427e84c4:/src/mac/carbon/thread.cpp diff --git a/src/mac/carbon/thread.cpp b/src/mac/carbon/thread.cpp index b8302e571f..da4c2c1c9c 100644 --- a/src/mac/carbon/thread.cpp +++ b/src/mac/carbon/thread.cpp @@ -25,19 +25,8 @@ #include "wx/thread.h" -#ifdef __WXMAC__ -#ifdef __DARWIN__ - #include -#else - #include - #include -#endif - +#include #include "wx/mac/uma.h" -#endif - -#include "wx/mac/macnotfy.h" - // the possible states of the thread: // ("=>" shows all possible transitions from this state) @@ -136,15 +125,9 @@ void wxCriticalSection::Leave() // wxMutex implementation // ---------------------------------------------------------------------------- -#if TARGET_API_MAC_OSX #define wxUSE_MAC_SEMAPHORE_MUTEX 0 #define wxUSE_MAC_CRITICAL_REGION_MUTEX 1 #define wxUSE_MAC_PTHREADS_MUTEX 0 -#else -#define wxUSE_MAC_SEMAPHORE_MUTEX 0 -#define wxUSE_MAC_CRITICAL_REGION_MUTEX 1 -#define wxUSE_MAC_PTHREADS_MUTEX 0 -#endif #if wxUSE_MAC_PTHREADS_MUTEX @@ -418,10 +401,10 @@ public: wxMutexInternal( wxMutexType mutexType ); virtual ~wxMutexInternal(); - bool IsOk() const - { return m_isOk; } + bool IsOk() const { return m_isOk; } - wxMutexError Lock() ; + wxMutexError Lock() { return Lock(kDurationForever); } + wxMutexError Lock(unsigned long ms); wxMutexError TryLock(); wxMutexError Unlock(); @@ -430,7 +413,7 @@ private: bool m_isOk ; }; -wxMutexInternal::wxMutexInternal( wxMutexType mutexType ) +wxMutexInternal::wxMutexInternal( wxMutexType WXUNUSED(mutexType) ) { m_isOk = false; m_critRegion = kInvalidID; @@ -451,15 +434,23 @@ wxMutexInternal::~wxMutexInternal() MPYield(); } -wxMutexError wxMutexInternal::Lock() +wxMutexError wxMutexInternal::Lock(unsigned long ms) { wxCHECK_MSG( m_isOk , wxMUTEX_MISC_ERROR , wxT("Invalid Mutex") ); - OSStatus err = MPEnterCriticalRegion( m_critRegion, kDurationForever); - if (err != noErr) + OSStatus err = MPEnterCriticalRegion( m_critRegion, ms ); + switch ( err ) { - wxLogSysError(wxT("Could not lock mutex")); - return wxMUTEX_MISC_ERROR; + case noErr: + break; + + case kMPTimeoutErr: + wxASSERT_MSG( ms != kDurationForever, wxT("unexpected timeout") ); + return wxMUTEX_TIMEOUT; + + default: + wxLogSysError(wxT("Could not lock mutex")); + return wxMUTEX_MISC_ERROR; } return wxMUTEX_NO_ERROR; @@ -829,7 +820,7 @@ wxCondError wxConditionInternal::WaitTimeout( unsigned long milliseconds ) wxSemaError err = m_semaphore.WaitTimeout(milliseconds); - if ( err == wxSEMA_BUSY ) + if ( err == wxSEMA_TIMEOUT ) { // another potential race condition exists here it is caused when a // 'waiting' thread timesout, and returns from WaitForSingleObject, but @@ -1247,9 +1238,7 @@ bool wxThread::IsMain() void wxThread::Yield() { -#if TARGET_API_MAC_OSX CFRunLoopRunInMode( kCFRunLoopDefaultMode , 0 , true ) ; -#endif MPYield(); } @@ -1270,7 +1259,7 @@ unsigned long wxThread::GetCurrentId() return (unsigned long)MPCurrentTaskID(); } -bool wxThread::SetConcurrency( size_t level ) +bool wxThread::SetConcurrency( size_t WXUNUSED(level) ) { // Cannot be set in MacOS. return false; @@ -1640,7 +1629,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule) bool wxThreadModule::OnInit() { - bool hasThreadManager = MPLibraryIsLoaded(); + bool hasThreadManager = +#ifdef __LP64__ + true ; // TODO VERIFY IN NEXT BUILD +#else + MPLibraryIsLoaded(); +#endif if ( !hasThreadManager ) {