Added (and documented :) optional stack size specification for wxThread.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13322 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -74,10 +74,12 @@ stack.
|
||||
|
||||
\membersection{wxThread::Create}\label{wxthreadcreate}
|
||||
|
||||
\func{wxThreadError}{Create}{\void}
|
||||
\func{wxThreadError}{Create}{\param{unsigned int }{stackSize = 0}}
|
||||
|
||||
Creates a new thread. The thread object is created in the suspended state, and you
|
||||
should call \helpref{Run}{wxthreadrun} to start running it.
|
||||
should call \helpref{Run}{wxthreadrun} to start running it. You may optionally
|
||||
specify the stack size to be allocated to it (Ignored on platforms that don't
|
||||
support setting it explicitly, eg. Unix).
|
||||
|
||||
\wxheading{Return value}
|
||||
|
||||
|
@@ -303,8 +303,15 @@ public:
|
||||
// from _another_ thread (typically the thread that created this one, e.g.
|
||||
// the main thread), not from the thread itself
|
||||
|
||||
// create a new thread - call Run() to start it
|
||||
wxThreadError Create();
|
||||
// create a new thread and optionally set the stack size on
|
||||
// platforms that support that - call Run() to start it
|
||||
// (special cased for watcom which won't accept 0 default)
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
wxThreadError Create(unsigned int stackSize = 10240);
|
||||
#else
|
||||
wxThreadError Create(unsigned int stackSize = 0);
|
||||
#endif
|
||||
|
||||
// starts execution of the thread - from the moment Run() is called
|
||||
// the execution of wxThread::Entry() may start at any moment, caller
|
||||
@@ -525,3 +532,5 @@ public:
|
||||
#endif // wxUSE_THREADS
|
||||
|
||||
#endif // __THREADH__
|
||||
|
||||
// vi:sts=4:sw=4:et
|
||||
|
@@ -305,7 +305,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();
|
||||
@@ -335,7 +335,6 @@ private:
|
||||
ThreadID m_tid; // thread id
|
||||
void* m_result;
|
||||
static ThreadEntryUPP s_threadEntry ;
|
||||
public :
|
||||
};
|
||||
|
||||
static wxArrayPtrVoid s_threads ;
|
||||
@@ -375,7 +374,7 @@ void wxThreadInternal::SetPriority(unsigned int priority)
|
||||
// Priorities don't exist on Mac
|
||||
}
|
||||
|
||||
bool wxThreadInternal::Create(wxThread *thread)
|
||||
bool wxThreadInternal::Create(wxThread *thread, unsigned int stackSize)
|
||||
{
|
||||
if ( s_threadEntry == NULL )
|
||||
{
|
||||
@@ -384,7 +383,7 @@ bool wxThreadInternal::Create(wxThread *thread)
|
||||
OSErr err = NewThread( kCooperativeThread,
|
||||
s_threadEntry,
|
||||
(void*) thread,
|
||||
0 ,
|
||||
stackSize,
|
||||
kNewSuspend,
|
||||
&m_result,
|
||||
&m_tid );
|
||||
@@ -542,11 +541,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;
|
||||
@@ -858,3 +857,4 @@ bool WXDLLEXPORT wxIsWaitingForThread()
|
||||
|
||||
#endif // wxUSE_THREADS
|
||||
|
||||
// vi:sts=4:sw=4:et
|
||||
|
@@ -305,7 +305,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();
|
||||
@@ -335,7 +335,6 @@ private:
|
||||
ThreadID m_tid; // thread id
|
||||
void* m_result;
|
||||
static ThreadEntryUPP s_threadEntry ;
|
||||
public :
|
||||
};
|
||||
|
||||
static wxArrayPtrVoid s_threads ;
|
||||
@@ -375,7 +374,7 @@ void wxThreadInternal::SetPriority(unsigned int priority)
|
||||
// Priorities don't exist on Mac
|
||||
}
|
||||
|
||||
bool wxThreadInternal::Create(wxThread *thread)
|
||||
bool wxThreadInternal::Create(wxThread *thread, unsigned int stackSize)
|
||||
{
|
||||
if ( s_threadEntry == NULL )
|
||||
{
|
||||
@@ -384,7 +383,7 @@ bool wxThreadInternal::Create(wxThread *thread)
|
||||
OSErr err = NewThread( kCooperativeThread,
|
||||
s_threadEntry,
|
||||
(void*) thread,
|
||||
0 ,
|
||||
stackSize,
|
||||
kNewSuspend,
|
||||
&m_result,
|
||||
&m_tid );
|
||||
@@ -542,11 +541,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;
|
||||
@@ -858,3 +857,4 @@ bool WXDLLEXPORT wxIsWaitingForThread()
|
||||
|
||||
#endif // wxUSE_THREADS
|
||||
|
||||
// vi:sts=4:sw=4:et
|
||||
|
@@ -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,7 +514,7 @@ 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
|
||||
@@ -523,11 +523,7 @@ bool wxThreadInternal::Create(wxThread *thread)
|
||||
m_hThread = (HANDLE)_beginthreadex
|
||||
(
|
||||
NULL, // default security
|
||||
#ifdef __WATCOMC__
|
||||
10240, // stack size can't be NULL in Watcom
|
||||
#else
|
||||
0, // default stack size
|
||||
#endif
|
||||
stackSize,
|
||||
wxThreadInternal::WinThreadStart, // entry point
|
||||
thread,
|
||||
CREATE_SUSPENDED,
|
||||
@@ -537,7 +533,7 @@ bool wxThreadInternal::Create(wxThread *thread)
|
||||
m_hThread = ::CreateThread
|
||||
(
|
||||
NULL, // default security
|
||||
0, // default stack size
|
||||
stackSize, // default stack size
|
||||
wxThreadInternal::WinThreadStart, // thread entry point
|
||||
(LPVOID)thread, // parameter
|
||||
CREATE_SUSPENDED, // flags
|
||||
@@ -756,11 +752,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 +1240,5 @@ bool WXDLLEXPORT wxIsWaitingForThread()
|
||||
}
|
||||
|
||||
#endif // wxUSE_THREADS
|
||||
|
||||
// vi:sts=4:sw=4:et
|
||||
|
@@ -938,7 +938,7 @@ wxThread::wxThread(wxThreadKind kind)
|
||||
m_isDetached = kind == wxTHREAD_DETACHED;
|
||||
}
|
||||
|
||||
wxThreadError wxThread::Create()
|
||||
wxThreadError wxThread::Create(unsigned int WXUNUSED(stackSize))
|
||||
{
|
||||
if ( m_internal->GetState() != STATE_NEW )
|
||||
{
|
||||
|
Reference in New Issue
Block a user