Formatting

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54293 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2008-06-20 07:43:26 +00:00
parent bb3e552672
commit 8b9aed29b7

View File

@@ -343,6 +343,7 @@ public:
corresponding wxThread object yourself if you did not create it on the stack. corresponding wxThread object yourself if you did not create it on the stack.
In contrast, detached threads are of the "fire-and-forget" kind: you only have to In contrast, detached threads are of the "fire-and-forget" kind: you only have to
start a detached thread and it will terminate and destroy itself. start a detached thread and it will terminate and destroy itself.
@section overview_deletionwxthread wxThread Deletion @section overview_deletionwxthread wxThread Deletion
Regardless of whether it has terminated or not, you should call Regardless of whether it has terminated or not, you should call
Wait() on a joinable thread to release its memory, as outlined in Wait() on a joinable thread to release its memory, as outlined in
@@ -370,6 +371,7 @@ public:
the resources associated with the object (although the wxThread object of the resources associated with the object (although the wxThread object of
detached threads will still be deleted) and could leave the C runtime detached threads will still be deleted) and could leave the C runtime
library in an undefined state. library in an undefined state.
@section overview_secondarythreads wxWidgets Calls in Secondary Threads @section overview_secondarythreads wxWidgets Calls in Secondary Threads
All threads other than the "main application thread" (the one All threads other than the "main application thread" (the one
wxApp::OnInit or your main function runs in, for example) are considered wxApp::OnInit or your main function runs in, for example) are considered
@@ -385,10 +387,10 @@ public:
A workaround for some wxWidgets ports is calling wxMutexGUIEnter() A workaround for some wxWidgets ports is calling wxMutexGUIEnter()
before any GUI calls and then calling wxMutexGUILeave() afterwords. However, before any GUI calls and then calling wxMutexGUILeave() afterwords. However,
the recommended way is to simply process the GUI calls in the main thread the recommended way is to simply process the GUI calls in the main thread
through an event that is posted by either wxPostEvent() or through an event that is posted by either wxQueueEvent().
wxEvtHandler::AddPendingEvent. This does not imply that calls to these This does not imply that calls to these classes are thread-safe, however,
classes are thread-safe, however, as most wxWidgets classes are not as most wxWidgets classes are not thread-safe, including wxString.
thread-safe, including wxString.
@section overview_pollwxThread Don't Poll a wxThread @section overview_pollwxThread Don't Poll a wxThread
A common problem users experience with wxThread is that in their main thread A common problem users experience with wxThread is that in their main thread
they will check the thread every now and then to see if it has ended through they will check the thread every now and then to see if it has ended through
@@ -415,19 +417,13 @@ class wxThread
{ {
public: public:
/** /**
This constructor creates a new detached (default) or joinable C++ thread This constructor creates a new detached (default) or joinable C++
object. It thread object. It does not create or start execution of the real thread --
does not create or start execution of the real thread -- for this you should for this you should use the Create() and Run() methods.
use the Create() and Run() methods.
The possible values for @a kind parameters are: The possible values for @a kind parameters are:
- @b wxTHREAD_DETACHED - Creates a detached thread.
@b wxTHREAD_DETACHED - @b wxTHREAD_JOINABLE - Creates a joinable thread.
Creates a detached thread.
@b wxTHREAD_JOINABLE
Creates a joinable thread.
*/ */
wxThread(wxThreadKind kind = wxTHREAD_DETACHED); wxThread(wxThreadKind kind = wxTHREAD_DETACHED);
@@ -444,9 +440,8 @@ public:
~wxThread(); ~wxThread();
/** /**
Creates a new thread. The thread object is created in the suspended state, and Creates a new thread. The thread object is created in the suspended state,
you and you should call Run() to start running it. You may optionally
should call Run() to start running it. You may optionally
specify the stack size to be allocated to it (Ignored on platforms that don't specify the stack size to be allocated to it (Ignored on platforms that don't
support setting it explicitly, eg. Unix system without support setting it explicitly, eg. Unix system without
@c pthread_attr_setstacksize). If you do not specify the stack size, @c pthread_attr_setstacksize). If you do not specify the stack size,
@@ -464,6 +459,9 @@ public:
thread. thread.
@return One of: @return One of:
- @b wxTHREAD_NO_ERROR - No error.
- @b wxTHREAD_NO_RESOURCE - There were insufficient resources to create the thread.
- @b wxTHREAD_NO_RUNNING - The thread is already running
*/ */
wxThreadError Create(unsigned int stackSize = 0); wxThreadError Create(unsigned int stackSize = 0);
@@ -523,19 +521,11 @@ public:
/** /**
Gets the priority of the thread, between zero and 100. Gets the priority of the thread, between zero and 100.
The following priorities are defined: The following priorities are defined:
- @b WXTHREAD_MIN_PRIORITY: 0
@b WXTHREAD_MIN_PRIORITY - @b WXTHREAD_DEFAULT_PRIORITY: 50
- @b WXTHREAD_MAX_PRIORITY: 100
0
@b WXTHREAD_DEFAULT_PRIORITY
50
@b WXTHREAD_MAX_PRIORITY
100
*/ */
int GetPriority() const; int GetPriority() const;
@@ -588,7 +578,7 @@ public:
cannot kill itself. cannot kill itself.
It is also an error to call this function for a thread which is not running or 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 @c wxTHREAD_NOT_RUNNING error will be returned. a @b wxTHREAD_NOT_RUNNING error will be returned.
*/ */
wxThreadError Kill(); wxThreadError Kill();
@@ -636,19 +626,11 @@ public:
Sets the priority of the thread, between 0 and 100. It can only be set Sets the priority of the thread, between 0 and 100. It can only be set
after calling Create() but before calling after calling Create() but before calling
Run(). Run().
The following priorities are already defined:
@b WXTHREAD_MIN_PRIORITY The following priorities are defined:
- @b WXTHREAD_MIN_PRIORITY: 0
0 - @b WXTHREAD_DEFAULT_PRIORITY: 50
- @b WXTHREAD_MAX_PRIORITY: 100
@b WXTHREAD_DEFAULT_PRIORITY
50
@b WXTHREAD_MAX_PRIORITY
100
*/ */
void SetPriority(int priority); void SetPriority(int priority);
@@ -660,33 +642,28 @@ public:
static void Sleep(unsigned long milliseconds); static void Sleep(unsigned long milliseconds);
/** /**
This function should be called periodically by the thread to ensure that calls This function should be called periodically by the thread to ensure that
to Pause() and Delete() will calls to Pause() and Delete() will work. If it returns @true, the thread
work. If it returns @true, the thread should exit as soon as possible. should exit as soon as possible. Notice that under some platforms (POSIX),
Notice that under some platforms (POSIX), implementation of implementation of Pause() also relies on this function being called, so
Pause() also relies on this function being called, so
not calling it would prevent both stopping and suspending thread from working. not calling it would prevent both stopping and suspending thread from working.
*/ */
virtual bool TestDestroy(); virtual bool TestDestroy();
/** /**
Return the thread object for the calling thread. @NULL is returned if the Return the thread object for the calling thread. @NULL is returned if
calling thread the calling thread is the main (GUI) thread, but IsMain() should be used
is the main (GUI) thread, but IsMain() should be used to test to test whether the thread is really the main one because @NULL may also
whether the thread is really the main one because @NULL may also be returned for be returned for the thread not created with wxThread class. Generally
the thread speaking, the return value for such a thread is undefined.
not created with wxThread class. Generally speaking, the return value for such
a thread
is undefined.
*/ */
static wxThread* This(); static wxThread* This();
/** /**
Waits for a joinable thread to terminate and returns the value the thread Waits for a joinable thread to terminate and returns the value the thread
returned from Entry() or @c (ExitCode)-1 on returned from Entry() or @c (ExitCode)-1 on error. Notice that, unlike
error. Notice that, unlike Delete() doesn't cancel the Delete() doesn't cancel the thread in any way so the caller waits for as
thread in any way so the caller waits for as long as it takes to the thread to long as it takes to the thread to exit.
exit.
You can only Wait() for joinable (not detached) threads. You can only Wait() for joinable (not detached) threads.
This function can only be called from another thread context. This function can only be called from another thread context.
See @ref overview_deletionwxthread "wxThread deletion" for a broader See @ref overview_deletionwxthread "wxThread deletion" for a broader
@@ -695,8 +672,8 @@ public:
ExitCode Wait() const; ExitCode Wait() const;
/** /**
Give the rest of the thread time slice to the system allowing the other threads Give the rest of the thread time slice to the system allowing the other
to run. threads to run.
Note that using this function is @b strongly discouraged, since in Note that using this function is @b strongly discouraged, since in
many cases it indicates a design weakness of your threading model (as many cases it indicates a design weakness of your threading model (as
does using Sleep functions). does using Sleep functions).