git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24660
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
extern wxList wxPendingDelete;
extern wxList *wxWinMacWindowList;
extern wxList *wxWinMacControlList;
extern wxList wxPendingDelete;
extern wxList *wxWinMacWindowList;
extern wxList *wxWinMacControlList;
+extern size_t g_numberOfThreads;
// statics for implementation
// statics for implementation
if ( wxTheApp->ProcessIdle() )
sleepTime = kEventDurationNoWait ;
else
if ( wxTheApp->ProcessIdle() )
sleepTime = kEventDurationNoWait ;
else
- sleepTime = kEventDurationForever ;
+ {
+ if (g_numberOfThreads)
+ {
+ sleepTime = kEventDurationNoWait;
+ }
+ else
+ {
+ sleepTime = kEventDurationSecond;
+ }
+ }
}
else if ( status == eventLoopQuitErr )
{
}
else if ( status == eventLoopQuitErr )
{
if ( wxTheApp->ProcessIdle() )
sleepTime = kEventDurationNoWait;
else
if ( wxTheApp->ProcessIdle() )
sleepTime = kEventDurationNoWait;
else
- sleepTime = GetCaretTime() / 2 ;
+ {
+ if (g_numberOfThreads)
+ {
+ sleepTime = kEventDurationNoWait;
+ }
+ else
+ {
+ sleepTime = kEventDurationSecond;
+ }
+ }
}
if ( event.what != kHighLevelEvent )
SetRectRgn( (RgnHandle) s_macCursorRgn , event.where.h , event.where.v , event.where.h + 1 , event.where.v + 1 ) ;
}
if ( event.what != kHighLevelEvent )
SetRectRgn( (RgnHandle) s_macCursorRgn , event.where.h , event.where.v , event.where.h + 1 , event.where.v + 1 ) ;
extern wxList wxPendingDelete;
extern wxList *wxWinMacWindowList;
extern wxList *wxWinMacControlList;
extern wxList wxPendingDelete;
extern wxList *wxWinMacWindowList;
extern wxList *wxWinMacControlList;
+extern size_t g_numberOfThreads;
// statics for implementation
// statics for implementation
if ( wxTheApp->ProcessIdle() )
sleepTime = kEventDurationNoWait ;
else
if ( wxTheApp->ProcessIdle() )
sleepTime = kEventDurationNoWait ;
else
- sleepTime = kEventDurationForever ;
+ {
+ if (g_numberOfThreads)
+ {
+ sleepTime = kEventDurationNoWait;
+ }
+ else
+ {
+ sleepTime = kEventDurationSecond;
+ }
+ }
}
else if ( status == eventLoopQuitErr )
{
}
else if ( status == eventLoopQuitErr )
{
if ( wxTheApp->ProcessIdle() )
sleepTime = kEventDurationNoWait;
else
if ( wxTheApp->ProcessIdle() )
sleepTime = kEventDurationNoWait;
else
- sleepTime = GetCaretTime() / 2 ;
+ {
+ if (g_numberOfThreads)
+ {
+ sleepTime = kEventDurationNoWait;
+ }
+ else
+ {
+ sleepTime = kEventDurationSecond;
+ }
+ }
}
if ( event.what != kHighLevelEvent )
SetRectRgn( (RgnHandle) s_macCursorRgn , event.where.h , event.where.v , event.where.h + 1 , event.where.v + 1 ) ;
}
if ( event.what != kHighLevelEvent )
SetRectRgn( (RgnHandle) s_macCursorRgn , event.where.h , event.where.v , event.where.h + 1 , event.where.v + 1 ) ;
static ThreadID gs_idMainThread = kNoThreadID ;
static bool gs_waitingForThread = FALSE ;
static ThreadID gs_idMainThread = kNoThreadID ;
static bool gs_waitingForThread = FALSE ;
+size_t g_numberOfThreads = 0;
// ============================================================================
// MacOS implementation of thread classes
// ============================================================================
// MacOS implementation of thread classes
- } while( clock() - start < milliseconds / 1000.0 * CLOCKS_PER_SEC ) ;
+ } while( clock() - start < milliseconds * CLOCKS_PER_SEC / 1000.0 ) ;
}
int wxThread::GetCPUCount()
}
int wxThread::GetCPUCount()
wxThread::wxThread(wxThreadKind kind)
{
wxThread::wxThread(wxThreadKind kind)
{
m_internal = new wxThreadInternal();
m_isDetached = kind == wxTHREAD_DETACHED;
m_internal = new wxThreadInternal();
m_isDetached = kind == wxTHREAD_DETACHED;
+ 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;
s_threads.Remove( (void*) this ) ;
if (m_internal != NULL) {
delete m_internal;
static ThreadID gs_idMainThread = kNoThreadID ;
static bool gs_waitingForThread = FALSE ;
static ThreadID gs_idMainThread = kNoThreadID ;
static bool gs_waitingForThread = FALSE ;
+size_t g_numberOfThreads = 0;
// ============================================================================
// MacOS implementation of thread classes
// ============================================================================
// MacOS implementation of thread classes
- } while( clock() - start < milliseconds / 1000.0 * CLOCKS_PER_SEC ) ;
+ } while( clock() - start < milliseconds * CLOCKS_PER_SEC / 1000.0 ) ;
}
int wxThread::GetCPUCount()
}
int wxThread::GetCPUCount()
wxThread::wxThread(wxThreadKind kind)
{
wxThread::wxThread(wxThreadKind kind)
{
m_internal = new wxThreadInternal();
m_isDetached = kind == wxTHREAD_DETACHED;
m_internal = new wxThreadInternal();
m_isDetached = kind == wxTHREAD_DETACHED;
+ 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;
s_threads.Remove( (void*) this ) ;
if (m_internal != NULL) {
delete m_internal;