#include "wx/thread.h"
-#ifdef __WXMAC__
-#ifdef __DARWIN__
- #include <CoreServices/CoreServices.h>
-#else
- #include <DriverServices.h>
- #include <Multiprocessing.h>
-#endif
-
+#include <CoreServices/CoreServices.h>
#include "wx/mac/uma.h"
-#endif
-
-#include "wx/mac/macnotfy.h"
-
// the possible states of the thread:
// ("=>" shows all possible transitions from this state)
// 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
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();
bool m_isOk ;
};
-wxMutexInternal::wxMutexInternal( wxMutexType mutexType )
+wxMutexInternal::wxMutexInternal( wxMutexType WXUNUSED(mutexType) )
{
m_isOk = false;
m_critRegion = kInvalidID;
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;
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
void wxThread::Yield()
{
-#if TARGET_API_MAC_OSX
CFRunLoopRunInMode( kCFRunLoopDefaultMode , 0 , true ) ;
-#endif
MPYield();
}
return (unsigned long)MPCurrentTaskID();
}
-bool wxThread::SetConcurrency( size_t level )
+bool wxThread::SetConcurrency( size_t WXUNUSED(level) )
{
// Cannot be set in MacOS.
return false;
// GUI Serialization copied from MSW implementation
// ----------------------------------------------------------------------------
-void WXDLLIMPEXP_BASE wxMutexGuiEnter()
+void wxMutexGuiEnterImpl()
{
// this would dead lock everything...
wxASSERT_MSG( !wxThread::IsMain(),
gs_critsectGui->Enter();
}
-void WXDLLIMPEXP_BASE wxMutexGuiLeave()
+void wxMutexGuiLeaveImpl()
{
wxCriticalSectionLocker enter(*gs_critsectWaitingForGui);