diff options
Diffstat (limited to 'doc/html/qthread.html')
-rw-r--r-- | doc/html/qthread.html | 252 |
1 files changed, 252 insertions, 0 deletions
diff --git a/doc/html/qthread.html b/doc/html/qthread.html new file mode 100644 index 0000000..4a5827c --- /dev/null +++ b/doc/html/qthread.html @@ -0,0 +1,252 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qthread.cpp:52 --> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> +<title>QThread Class</title> +<style type="text/css"><!-- +fn { margin-left: 1cm; text-indent: -1cm; } +a:link { color: #004faf; text-decoration: none } +a:visited { color: #672967; text-decoration: none } +body { background: #ffffff; color: black; } +--></style> +</head> +<body> + +<table border="0" cellpadding="0" cellspacing="0" width="100%"> +<tr bgcolor="#E5E5E5"> +<td valign=center> + <a href="index.html"> +<font color="#004faf">Home</font></a> + | <a href="classes.html"> +<font color="#004faf">All Classes</font></a> + | <a href="mainclasses.html"> +<font color="#004faf">Main Classes</font></a> + | <a href="annotated.html"> +<font color="#004faf">Annotated</font></a> + | <a href="groups.html"> +<font color="#004faf">Grouped Classes</font></a> + | <a href="functions.html"> +<font color="#004faf">Functions</font></a> +</td> +<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QThread Class Reference</h1> + +<p>The QThread class provides platform-independent threads. +<a href="#details">More...</a> +<p>All the functions in this class are <a href="threads.html#threadsafe">thread-safe</a> when Qt is built with thread support.</p> +<p><tt>#include <<a href="qthread-h.html">qthread.h</a>></tt> +<p>Inherits <a href="qt.html">Qt</a>. +<p><a href="qthread-members.html">List of all member functions.</a> +<h2>Public Members</h2> +<ul> +<li class=fn><a href="#QThread"><b>QThread</b></a> ( unsigned int stackSize = 0 )</li> +<li class=fn>virtual <a href="#~QThread"><b>~QThread</b></a> ()</li> +<li class=fn>bool <a href="#wait"><b>wait</b></a> ( unsigned long time = ULONG_MAX )</li> +<li class=fn>enum <a href="#Priority-enum"><b>Priority</b></a> { IdlePriority, LowestPriority, LowPriority, NormalPriority, HighPriority, HighestPriority, TimeCriticalPriority, InheritPriority }</li> +<li class=fn>void <a href="#start"><b>start</b></a> ( Priority priority = InheritPriority )</li> +<li class=fn>void <a href="#terminate"><b>terminate</b></a> ()</li> +<li class=fn>bool <a href="#finished"><b>finished</b></a> () const</li> +<li class=fn>bool <a href="#running"><b>running</b></a> () const</li> +</ul> +<h2>Static Public Members</h2> +<ul> +<li class=fn>Qt::HANDLE <a href="#currentThread"><b>currentThread</b></a> ()</li> +<li class=fn>void postEvent ( QObject * receiver, QEvent * event ) <em>(obsolete)</em></li> +<li class=fn>void <a href="#exit"><b>exit</b></a> ()</li> +</ul> +<h2>Protected Members</h2> +<ul> +<li class=fn>virtual void <a href="#run"><b>run</b></a> () = 0</li> +</ul> +<h2>Static Protected Members</h2> +<ul> +<li class=fn>void <a href="#sleep"><b>sleep</b></a> ( unsigned long secs )</li> +<li class=fn>void <a href="#msleep"><b>msleep</b></a> ( unsigned long msecs )</li> +<li class=fn>void <a href="#usleep"><b>usleep</b></a> ( unsigned long usecs )</li> +</ul> +<hr><a name="details"></a><h2>Detailed Description</h2> + + + +The QThread class provides platform-independent threads. +<p> + +<p> A QThread represents a separate thread of control within the +program; it shares data with all the other threads within the +process but executes independently in the way that a separate +program does on a multitasking operating system. Instead of +starting in main(), QThreads begin executing in <a href="#run">run</a>(). You inherit +run() to include your code. For example: +<p> <pre> + class MyThread : public QThread { + + public: + + virtual void run(); + + }; + + void MyThread::<a href="#run">run</a>() + { + for( int count = 0; count < 20; count++ ) { + <a href="#sleep">sleep</a>( 1 ); + <a href="qapplication.html#qDebug">qDebug</a>( "Ping!" ); + } + } + + int main() + { + MyThread a; + MyThread b; + a.<a href="#start">start</a>(); + b.<a href="#start">start</a>(); + a.<a href="#wait">wait</a>(); + b.<a href="#wait">wait</a>(); + } + </pre> + +<p> This will start two threads, each of which writes Ping! 20 times +to the screen and exits. The <a href="#wait">wait</a>() calls at the end of main() are +necessary because exiting main() ends the program, unceremoniously +killing all other threads. Each MyThread stops executing when it +reaches the end of MyThread::run(), just as an application does +when it leaves main(). +<p> <p>See also <a href="threads.html">Thread Support in Qt</a>, <a href="environment.html">Environment Classes</a>, and <a href="thread.html">Threading</a>. + +<hr><h2>Member Type Documentation</h2> +<h3 class=fn><a name="Priority-enum"></a>QThread::Priority</h3> + +<p> This enum type indicates how the operating system should schedule +newly created threads. +<ul> +<li><tt>QThread::IdlePriority</tt> - scheduled only when no other threads are +running. +<li><tt>QThread::LowestPriority</tt> - scheduled less often than LowPriority. +<li><tt>QThread::LowPriority</tt> - scheduled less often than NormalPriority. +<li><tt>QThread::NormalPriority</tt> - the default priority of the operating +system. +<li><tt>QThread::HighPriority</tt> - scheduled more often than NormalPriority. +<li><tt>QThread::HighestPriority</tt> - scheduled more often then HighPriority. +<li><tt>QThread::TimeCriticalPriority</tt> - scheduled as often as possible. +<li><tt>QThread::InheritPriority</tt> - use the same priority as the creating +thread. This is the default. +</ul> +<hr><h2>Member Function Documentation</h2> +<h3 class=fn><a name="QThread"></a>QThread::QThread ( unsigned int stackSize = 0 ) +</h3> +Constructs a new thread. The thread does not begin executing until +<a href="#start">start</a>() is called. +<p> If <em>stackSize</em> is greater than zero, the maximum stack size is +set to <em>stackSize</em> bytes, otherwise the maximum stack size is +automatically determined by the operating system. +<p> <b>Warning:</b> Most operating systems place minimum and maximum limits +on thread stack sizes. The thread will fail to start if the stack +size is outside these limits. + +<h3 class=fn><a name="~QThread"></a>QThread::~QThread ()<tt> [virtual]</tt> +</h3> +QThread destructor. +<p> Note that deleting a QThread object will not stop the execution of +the thread it represents. Deleting a running QThread (i.e. +<a href="#finished">finished</a>() returns FALSE) will probably result in a program crash. +You can <a href="#wait">wait</a>() on a thread to make sure that it has finished. + +<h3 class=fn>Qt::HANDLE <a name="currentThread"></a>QThread::currentThread ()<tt> [static]</tt> +</h3> +This returns the thread handle of the currently executing thread. +<p> <b>Warning:</b> The handle returned by this function is used for internal +purposes and should <em>not</em> be used in any application code. On +Windows, the returned value is a pseudo handle for the current +thread, and it cannot be used for numerical comparison. + +<h3 class=fn>void <a name="exit"></a>QThread::exit ()<tt> [static]</tt> +</h3> +Ends the execution of the calling thread and wakes up any threads +waiting for its termination. + +<h3 class=fn>bool <a name="finished"></a>QThread::finished () const +</h3> +Returns TRUE if the thread is finished; otherwise returns FALSE. + +<h3 class=fn>void <a name="msleep"></a>QThread::msleep ( unsigned long msecs )<tt> [static protected]</tt> +</h3> +System independent sleep. This causes the current thread to sleep +for <em>msecs</em> milliseconds + +<h3 class=fn>void <a name="postEvent"></a>QThread::postEvent ( <a href="qobject.html">QObject</a> * receiver, <a href="qevent.html">QEvent</a> * event )<tt> [static]</tt> +</h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. +<p> Use <a href="qapplication.html#postEvent">QApplication::postEvent</a>() instead. + +<h3 class=fn>void <a name="run"></a>QThread::run ()<tt> [pure virtual protected]</tt> +</h3> + +<p> This method is pure virtual, and must be implemented in derived +classes in order to do useful work. Returning from this method +will end the execution of the thread. +<p> <p>See also <a href="#wait">wait</a>(). + +<h3 class=fn>bool <a name="running"></a>QThread::running () const +</h3> +Returns TRUE if the thread is running; otherwise returns FALSE. + +<h3 class=fn>void <a name="sleep"></a>QThread::sleep ( unsigned long secs )<tt> [static protected]</tt> +</h3> +System independent sleep. This causes the current thread to sleep +for <em>secs</em> seconds. + +<h3 class=fn>void <a name="start"></a>QThread::start ( <a href="qthread.html#Priority-enum">Priority</a> priority = InheritPriority ) +</h3> +Begins execution of the thread by calling <a href="#run">run</a>(), which should be +reimplemented in a QThread subclass to contain your code. The +operating system will schedule the thread according to the <em>priority</em> argument. +<p> If you try to start a thread that is already running, this +function will wait until the the thread has finished and then +restart the thread. +<p> <p>See also <a href="#Priority-enum">Priority</a>. + +<h3 class=fn>void <a name="terminate"></a>QThread::terminate () +</h3> +This function terminates the execution of the thread. The thread +may or may not be terminated immediately, depending on the +operating system's scheduling policies. Use <a href="#wait">QThread::wait</a>() +after <a href="#terminate">terminate</a>() for synchronous termination. +<p> When the thread is terminated, all threads waiting for the +the thread to finish will be woken up. +<p> <b>Warning:</b> This function is dangerous, and its use is discouraged. +The thread can be terminated at any point in its code path. Threads +can be terminated while modifying data. There is no chance for +the thread to cleanup after itself, unlock any held mutexes, etc. +In short, use this function only if <em>absolutely</em> necessary. + +<h3 class=fn>void <a name="usleep"></a>QThread::usleep ( unsigned long usecs )<tt> [static protected]</tt> +</h3> +System independent sleep. This causes the current thread to sleep +for <em>usecs</em> microseconds + +<h3 class=fn>bool <a name="wait"></a>QThread::wait ( unsigned long time = ULONG_MAX ) +</h3> +A thread calling this function will block until either of these +conditions is met: +<p> <ul> +<li> The thread associated with this QThread object has finished +execution (i.e. when it returns from <a href="#run">run</a>()). This function +will return TRUE if the thread has finished. It also returns +TRUE if the thread has not been started yet. +<li> <em>time</em> milliseconds has elapsed. If <em>time</em> is ULONG_MAX (the +default), then the wait will never timeout (the thread must +return from <a href="#run">run</a>()). This function will return FALSE if the +wait timed out. +</ul> +<p> This provides similar functionality to the POSIX <tt>pthread_join()</tt> function. + +<!-- eof --> +<hr><p> +This file is part of the <a href="index.html">Qt toolkit</a>. +Copyright © 1995-2007 +<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center> +<table width=100% cellspacing=0 border=0><tr> +<td>Copyright © 2007 +<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a> +<td align=right><div align=right>Qt 3.3.8</div> +</table></div></address></body> +</html> |