/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/carbon/thread.cpp
-// Purpose: wxThread Implementation
-// Author: Original from Wolfram Gloger/Guilhem Lavaux/Vadim Zeitlin
+// Name: src/mac/carbon/thread.cpp
+// Purpose: wxThread Implementation
+// Author: Original from Wolfram Gloger/Guilhem Lavaux/Vadim Zeitlin
// Modified by: Aj Lavin, Stefan Csomor
-// Created: 04/22/98
-// RCS-ID: $Id$
-// Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998),
-// Vadim Zeitlin (1999), Stefan Csomor (2000)
-// Licence: wxWindows licence
+// Created: 04/22/98
+// RCS-ID: $Id$
+// Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998),
+// Vadim Zeitlin (1999), Stefan Csomor (2000)
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
#if defined(__BORLANDC__)
-#pragma hdrstop
+ #pragma hdrstop
#endif
#ifndef WX_PRECOMP
-#include "wx/wx.h"
+ #include "wx/wx.h"
+ #include "wx/module.h"
#endif
#if wxUSE_THREADS
-#include "wx/module.h"
#include "wx/thread.h"
#ifdef __WXMAC__
#else
#include <DriverServices.h>
#include <Multiprocessing.h>
- #include "wx/math.h"
#endif
#include "wx/mac/uma.h"
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();
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
wxThreadInternal *pthread = thread->m_internal;
// add to TLS so that This() will work
- verify_noerr( MPSetTaskStorageValue( gs_tlsForWXThread , (long) thread ) ) ;
+ verify_noerr( MPSetTaskStorageValue( gs_tlsForWXThread , (TaskStorageValue) thread ) ) ;
// have to declare this before pthread_cleanup_push() which defines a
// block!
bool wxThreadModule::OnInit()
{
- bool hasThreadManager = MPLibraryIsLoaded();
+ bool hasThreadManager =
+#ifdef __LP64__
+ true ; // TODO VERIFY IN NEXT BUILD
+#else
+ MPLibraryIsLoaded();
+#endif
if ( !hasThreadManager )
{