#ifdef __WXMAC__
#include <Threads.h>
#include "wx/mac/uma.h"
+#include "wx/mac/macnotfy.h"
#endif
#define INFINITE 0xFFFFFFFF
+
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
static ThreadID gs_idMainThread = kNoThreadID ;
static bool gs_waitingForThread = FALSE ;
+size_t g_numberOfThreads = 0;
// ============================================================================
// MacOS implementation of thread classes
}
bool IsOk() const { return m_mutex.IsOk() ; }
-
+
wxCondError Wait()
{
return WaitTimeout(0xFFFFFFFF );
}
-
+
wxCondError WaitTimeout(unsigned long msectimeout)
{
wxMacStCritical critical ;
{
wxMacStCritical critical ;
return wxCOND_NO_ERROR;
- }
+ }
wxArrayLong m_waiters ;
wxInt32 m_excessSignals ;
do
{
YieldToAnyThread();
- } while( clock() - start < milliseconds / 1000.0 * CLOCKS_PER_SEC ) ;
+ } while( clock() - start < milliseconds * CLOCKS_PER_SEC / 1000.0 ) ;
}
int wxThread::GetCPUCount()
wxThread::wxThread(wxThreadKind kind)
{
+ g_numberOfThreads++;
m_internal = new wxThreadInternal();
m_isDetached = kind == wxTHREAD_DETACHED;
wxThread::~wxThread()
{
+ if (g_numberOfThreads>0)
+ {
+ g_numberOfThreads--;
+ }
+#ifdef __WXDEBUG__
+ else
+ {
+ wxFAIL_MSG(wxT("More threads deleted than created."));
+ }
+#endif
+
s_threads.Remove( (void*) this ) ;
if (m_internal != NULL) {
delete m_internal;
#endif
if ( !hasThreadManager )
{
- wxMessageBox( wxT("Error") , wxT("Thread Support is not available on this System") , wxOK ) ;
+ wxLogSysError( wxT("Thread Support is not available on this System") );
return FALSE ;
}