#ifdef __WXDEBUG__
// Done this way to stop warnings during compilation about statement
// always being false
- int csSize = sizeof(CRITICAL_SECTION);
- int bSize = sizeof(m_buffer);
+ int csSize = sizeof(CRITICAL_SECTION);
+ int bSize = sizeof(m_buffer);
wxASSERT_MSG( csSize <= bSize,
_T("must increase buffer size in wx/thread.h") );
#endif
}
// create a new (suspended) thread (for the given thread object)
- bool Create(wxThread *thread);
+ bool Create(wxThread *thread, unsigned int stackSize);
// suspend/resume/terminate
bool Suspend();
}
}
-bool wxThreadInternal::Create(wxThread *thread)
+bool wxThreadInternal::Create(wxThread *thread, unsigned int stackSize)
{
// for compilers which have it, we should use C RTL function for thread
// creation instead of Win32 API one because otherwise we will have memory
// leaks if the thread uses C RTL (and most threads do)
#ifdef wxUSE_BEGIN_THREAD
+
+ // Watcom is reported to not like 0 stack size (which means "use default"
+ // for the other compilers and is also the default value for stackSize)
+#ifdef __WATCOMC__
+ if ( !stackSize )
+ stackSize = 10240;
+#endif // __WATCOMC__
+
m_hThread = (HANDLE)_beginthreadex
(
- NULL, // default security
-#ifdef __WATCOMC__
- 10240, // stack size can't be NULL in Watcom
-#else
- 0, // default stack size
-#endif
- wxThreadInternal::WinThreadStart, // entry point
- thread,
- CREATE_SUSPENDED,
- (unsigned int *)&m_tid
+ NULL, // default security
+ stackSize,
+ wxThreadInternal::WinThreadStart, // entry point
+ thread,
+ CREATE_SUSPENDED,
+ (unsigned int *)&m_tid
);
#else // compiler doesn't have _beginthreadex
m_hThread = ::CreateThread
(
NULL, // default security
- 0, // default stack size
+ stackSize, // stack size
wxThreadInternal::WinThreadStart, // thread entry point
(LPVOID)thread, // parameter
CREATE_SUSPENDED, // flags
// create/start thread
// -------------------
-wxThreadError wxThread::Create()
+wxThreadError wxThread::Create(unsigned int stackSize)
{
wxCriticalSectionLocker lock(m_critsect);
- if ( !m_internal->Create(this) )
+ if ( !m_internal->Create(this, stackSize) )
return wxTHREAD_NO_RESOURCE;
return wxTHREAD_NO_ERROR;
}
#endif // wxUSE_THREADS
+
+// vi:sts=4:sw=4:et