X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2f02cb8966964ea7a6f5d875ed9f3434ea05ab59..dbd25a9f8a83b30bc4e1fb7d79fe7cd2df965d0d:/docs/latex/wx/thread.tex diff --git a/docs/latex/wx/thread.tex b/docs/latex/wx/thread.tex index cfdbc20879..e531599ce2 100644 --- a/docs/latex/wx/thread.tex +++ b/docs/latex/wx/thread.tex @@ -43,12 +43,19 @@ None. \membersection{wxThread::wxThread}\label{wxthreadctor} -\func{}{wxThread}{\void} +\func{}{wxThread}{\param{wxThreadKind }{kind = wxTHREAD\_DETACHED}} Constructor creates a new detached (default) or joinable C++ thread object. It does not create (or starts execution of) the real thread - for this you should use \helpref{Create}{wxthreadcreate} and \helpref{Run}{wxthreadrun} methods. +The possible values for {\it kind} parameters are: +\twocolwidtha{7cm} +\begin{twocollist}\itemsep=0pt +\twocolitem{{\bf wxTHREAD\_DETACHED}}{Create a detached thread.} +\twocolitem{{\bf wxTHREAD\_JOINABLE}}{Create a joinable thread} +\end{twocollist} + \membersection{wxThread::\destruct{wxThread}} \func{}{\destruct{wxThread}}{\void} @@ -98,7 +105,7 @@ is not stopped during this function execution, so the 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 (it will be done in the destructor for joinable threads). @@ -127,6 +134,28 @@ joinable threads and is the value returned by \helpref{Wait}{wxthreadwait}. This function is called by wxWindows itself and should never be called directly. +\membersection{wxThread::Exit}\label{wxthreadexit} + +\func{void}{Exit}{\param{ExitCode }{exitcode = 0}} + +This is a protected function of wxThread class and thus can be called only +from a derived class. It also can be called only 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. +\helpref{wxThread::OnExit}{wxthreadonexit} will be called just before exiting. + +\membersection{wxThread::GetCPUCount}\label{wxthreadgetcpucount} + +\func{static int}{GetCPUCount}{\void} + +Returns the number of system CPUs or -1 if the value is unknown. + +\wxheading{See also} + +\helpref{SetConcurrency}{wxthreadsetconcurrency} + \membersection{wxThread::GetId}\label{wxthreadgetid} \constfunc{unsigned long}{GetId}{\void} @@ -188,16 +217,27 @@ be used with extreme care (and not used at all whenever possible)!} The resource allocated to the thread will not be freed and the state of the C runtime library may become inconsistent. Use \helpref{Delete()}{wxthreaddelete} instead. -For detached threads Kill() will also delete the associated C++ object. +For detached threads Kill() will also delete the associated C++ object, +however this will not happen for joinable threads and this means that you will +still have to delete the wxThread object yourself to avoid memory leaks. +In neither case \helpref{OnExit}{wxthreadonexit} of the dying thread will be +called, so no thread-specific cleanup will be performed. -This function can only be called from another thread context. +This function can only be called from another thread context, i.e. a thread +can not 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, +{\tt wxTHREAD\_NOT\_RUNNING} error will be returned. \membersection{wxThread::OnExit}\label{wxthreadonexit} \func{void}{OnExit}{\void} -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. +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 +\helpref{killed}{wxthreadkill}. This function should never be called directly. @@ -253,6 +293,17 @@ Resumes a thread suspended by the call to \helpref{Pause}{wxthreadpause}. This function can only be called from another thread context. +\membersection{wxThread::SetConcurrency}\label{wxthreadsetconcurrency} + +\func{static bool}{SetConcurrency}{\param{size\_t }{level}} + +Sets the thread concurrency level for this process. This is, roughly, the +number of threads that the system tries to schedule to run in parallel. +The value of $0$ for {\it level} may be used to set the default one. + +Returns TRUE on success or FALSE otherwise (for example, if this function is +not implemented for this platform (currently everything except Solaris)). + \membersection{wxThread::TestDestroy}\label{wxthreadtestdestroy} \func{bool}{TestDestroy}{\void} @@ -282,9 +333,9 @@ See also \helpref{Sleep()}{wxthreadsleep}. \constfunc{ExitCode}{Wait}{\void} -Waits until the thread terminates and returns its exit code or {\tt -(ExitCode)-1} on error. +Waits until the thread terminates and returns its exit code or {\tt (ExitCode)-1} on error. You can only Wait() for joinable (not detached) threads. This function can only be called from another thread context. +