X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/520d19362280287d359ed85e235aaa570301556b..2e25e7b7629b9c362d1fc689b536032a35441b8c:/docs/latex/wx/thread.tex diff --git a/docs/latex/wx/thread.tex b/docs/latex/wx/thread.tex index 34028509b8..33328eef99 100644 --- a/docs/latex/wx/thread.tex +++ b/docs/latex/wx/thread.tex @@ -63,7 +63,7 @@ The possible values for {\it kind} parameters are: \func{}{\destruct{wxThread}}{\void} The destructor frees the resources associated with the thread. Notice that you -should never delete a detached thread - you may only call +should never delete a detached thread - you may only call \helpref{Delete}{wxthreaddelete} on it or wait until it terminates (and auto destructs) itself. Because the detached threads delete themselves, they can only be allocated on the heap. @@ -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} @@ -96,17 +98,17 @@ One of: Calling \helpref{Delete}{wxthreaddelete} is a graceful way to terminate the thread. It asks the thread to terminate and, if the thread code is well -written, the thread will terminate after the next call to +written, the thread will terminate after the next call to \helpref{TestDestroy}{wxthreadtestdestroy} which should happen quite soon. -However, if the thread doesn't call \helpref{TestDestroy}{wxthreadtestdestroy} +However, if the thread doesn't call \helpref{TestDestroy}{wxthreadtestdestroy} often enough (or at all), the function will not return immediately, but wait until the thread terminates. As it may take a long time, and the message processing is not stopped during this function execution, message handlers may be called from inside it! Delete() may be called for thread in any state: running, paused or even not yet -created. Moreover, it must be called if \helpref{Create}{wxthreadcreate} or +created. Moreover, it must be called if \helpref{Create}{wxthreadcreate} or \helpref{Run}{wxthreadrun} failed for a detached thread to free the memory occupied by the thread object. This cleanup will be done in the destructor for joinable threads. @@ -144,7 +146,7 @@ from a derived class. It also can only be called in the context of this thread, i.e. a thread can only exit from itself, not from another thread. This function will terminate the OS thread (i.e. stop the associated path of -execution) and also delete the associated C++ object for detached threads. +execution) and also delete the associated C++ object for detached threads. \helpref{wxThread::OnExit}{wxthreadonexit} will be called just before exiting. \membersection{wxThread::GetCPUCount}\label{wxthreadgetcpucount} @@ -157,6 +159,14 @@ Returns the number of system CPUs or -1 if the value is unknown. \helpref{SetConcurrency}{wxthreadsetconcurrency} +\membersection{wxThread::GetCurrentId}\label{wxthreadgetcurrentid} + +\func{static unsigned long}{GetCurrentId}{\void} + +Returns the platform specific thread ID of the current thread as a +long. This can be used to uniquely identify threads, even if they are +not wxThreads. + \membersection{wxThread::GetId}\label{wxthreadgetid} \constfunc{unsigned long}{GetId}{\void} @@ -228,7 +238,7 @@ This function can only be called from another thread context, i.e. a thread cannot kill itself. It is also an error to call this function for a thread which is not running or -paused (in the latter case, the thread will be resumed first) - if you do it, +paused (in the latter case, the thread will be resumed first) - if you do it, a {\tt wxTHREAD\_NOT\_RUNNING} error will be returned. \membersection{wxThread::OnExit}\label{wxthreadonexit} @@ -237,7 +247,7 @@ a {\tt wxTHREAD\_NOT\_RUNNING} error will be returned. Called when the thread exits. This function is called in the context of the thread associated with the wxThread object, not in the context of the main -thread. This function will not be called if the thread was +thread. This function will not be called if the thread was \helpref{killed}{wxthreadkill}. This function should never be called directly. @@ -247,7 +257,7 @@ This function should never be called directly. \func{wxThreadError}{Pause}{\void} Suspends the thread. Under some implementations (Win32), the thread is -suspended immediately, under others it will only be suspended when it calls +suspended immediately, under others it will only be suspended when it calls \helpref{TestDestroy}{wxthreadtestdestroy} for the next time (hence, if the thread doesn't call it at all, it won't be suspended). @@ -257,7 +267,7 @@ This function can only be called from another thread context. \func{wxThreadError}{Run}{\void} -Starts the thread execution. Should be called after +Starts the thread execution. Should be called after \helpref{Create}{wxthreadcreate}. This function can only be called from another thread context. @@ -266,7 +276,9 @@ This function can only be called from another thread context. \func{void}{SetPriority}{\param{int}{ priority}} -Sets the priority of the thread, between zero and 100. This must be set before the thread is created. +Sets the priority of the thread, between $0$ and $100$. It can only be set +after calling \helpref{Create()}{wxthreadcreate} but before calling +\helpref{Run()}{wxthreadrun}. The following priorities are already defined: