projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
indent app name + version from the rest in about dialog; use i18n-friendly way of...
[wxWidgets.git]
/
src
/
mac
/
carbon
/
thread.cpp
diff --git
a/src/mac/carbon/thread.cpp
b/src/mac/carbon/thread.cpp
index 7a981d6206b2208b99136c3f7f9007386cabe3c1..04383b0f9478878676167e247fc3df36c570d27f 100644
(file)
--- a/
src/mac/carbon/thread.cpp
+++ b/
src/mac/carbon/thread.cpp
@@
-18,26
+18,15
@@
#ifndef WX_PRECOMP
#include "wx/wx.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
+ #include "wx/module.h"
#endif
#if wxUSE_THREADS
#endif
#if wxUSE_THREADS
-#include "wx/module.h"
#include "wx/thread.h"
#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"
#include "wx/mac/uma.h"
-#endif
-
-#include "wx/mac/macnotfy.h"
-
// the possible states of the thread:
// ("=>" shows all possible transitions from this state)
// the possible states of the thread:
// ("=>" shows all possible transitions from this state)
@@
-136,15
+125,9
@@
void wxCriticalSection::Leave()
// wxMutex implementation
// ----------------------------------------------------------------------------
// 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
#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
#if wxUSE_MAC_PTHREADS_MUTEX
@@
-418,10
+401,10
@@
public:
wxMutexInternal( wxMutexType mutexType );
virtual ~wxMutexInternal();
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();
wxMutexError TryLock();
wxMutexError Unlock();
@@
-430,7
+413,7
@@
private:
bool m_isOk ;
};
bool m_isOk ;
};
-wxMutexInternal::wxMutexInternal( wxMutexType
mutexType
)
+wxMutexInternal::wxMutexInternal( wxMutexType
WXUNUSED(mutexType)
)
{
m_isOk = false;
m_critRegion = kInvalidID;
{
m_isOk = false;
m_critRegion = kInvalidID;
@@
-451,15
+434,23
@@
wxMutexInternal::~wxMutexInternal()
MPYield();
}
MPYield();
}
-wxMutexError wxMutexInternal::Lock()
+wxMutexError wxMutexInternal::Lock(
unsigned long ms
)
{
wxCHECK_MSG( m_isOk , wxMUTEX_MISC_ERROR , wxT("Invalid Mutex") );
{
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;
}
return wxMUTEX_NO_ERROR;
@@
-829,7
+820,7
@@
wxCondError wxConditionInternal::WaitTimeout( unsigned long milliseconds )
wxSemaError err = m_semaphore.WaitTimeout(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
{
// 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()
{
void wxThread::Yield()
{
-#if TARGET_API_MAC_OSX
CFRunLoopRunInMode( kCFRunLoopDefaultMode , 0 , true ) ;
CFRunLoopRunInMode( kCFRunLoopDefaultMode , 0 , true ) ;
-#endif
MPYield();
}
MPYield();
}
@@
-1270,7
+1259,7
@@
unsigned long wxThread::GetCurrentId()
return (unsigned long)MPCurrentTaskID();
}
return (unsigned long)MPCurrentTaskID();
}
-bool wxThread::SetConcurrency( size_t
level
)
+bool wxThread::SetConcurrency( size_t
WXUNUSED(level)
)
{
// Cannot be set in MacOS.
return false;
{
// Cannot be set in MacOS.
return false;
@@
-1640,7
+1629,12
@@
IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
bool wxThreadModule::OnInit()
{
bool wxThreadModule::OnInit()
{
- bool hasThreadManager = MPLibraryIsLoaded();
+ bool hasThreadManager =
+#ifdef __LP64__
+ true ; // TODO VERIFY IN NEXT BUILD
+#else
+ MPLibraryIsLoaded();
+#endif
if ( !hasThreadManager )
{
if ( !hasThreadManager )
{
@@
-1685,7
+1679,7
@@
void wxThreadModule::OnExit()
// GUI Serialization copied from MSW implementation
// ----------------------------------------------------------------------------
// GUI Serialization copied from MSW implementation
// ----------------------------------------------------------------------------
-void
WXDLLIMPEXP_BASE wxMutexGuiEnter
()
+void
wxMutexGuiEnterImpl
()
{
// this would dead lock everything...
wxASSERT_MSG( !wxThread::IsMain(),
{
// this would dead lock everything...
wxASSERT_MSG( !wxThread::IsMain(),
@@
-1707,7
+1701,7
@@
void WXDLLIMPEXP_BASE wxMutexGuiEnter()
gs_critsectGui->Enter();
}
gs_critsectGui->Enter();
}
-void
WXDLLIMPEXP_BASE wxMutexGuiLeave
()
+void
wxMutexGuiLeaveImpl
()
{
wxCriticalSectionLocker enter(*gs_critsectWaitingForGui);
{
wxCriticalSectionLocker enter(*gs_critsectWaitingForGui);