X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/08d7397c9a177bc73c28017933cfdc4c57369202..4b2424bcadbc87babd3367d243b957e49333eeae:/src/msw/thread.cpp?ds=sidebyside diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp index ab8030e584..b654353bfc 100644 --- a/src/msw/thread.cpp +++ b/src/msw/thread.cpp @@ -351,8 +351,8 @@ wxCriticalSection::wxCriticalSection() #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 @@ -411,7 +411,7 @@ public: } // 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(); @@ -514,30 +514,34 @@ void wxThreadInternal::SetPriority(unsigned int priority) } } -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 @@ -643,6 +647,11 @@ int wxThread::GetCPUCount() return si.dwNumberOfProcessors; } +unsigned long wxThread::GetCurrentId() +{ + return (unsigned long)::GetCurrentThreadId(); +} + bool wxThread::SetConcurrency(size_t level) { wxASSERT_MSG( IsMain(), _T("should only be called from the main thread") ); @@ -756,11 +765,11 @@ wxThread::~wxThread() // 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; @@ -1244,3 +1253,5 @@ bool WXDLLEXPORT wxIsWaitingForThread() } #endif // wxUSE_THREADS + +// vi:sts=4:sw=4:et