⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classpthread.html

📁 pwlib开发文档
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>PThread class Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center><hr><h1>PThread Class Reference</h1><code>#include &lt;<a class="el" href="thread_8h-source.html">thread.h</a>&gt;</code><p><p>Inheritance diagram for PThread:<p><center><img src="classPThread.png" usemap="#PThread_map" border="0" alt=""></center><map name="PThread_map"><area href="classPObject.html" alt="PObject" shape="rect" coords="96,0,278,24"><area href="classPHTTPServiceThread.html" alt="PHTTPServiceThread" shape="rect" coords="0,112,182,136"><area href="classPProcess.html" alt="PProcess" shape="rect" coords="192,112,374,136"><area href="classPServiceProcess.html" alt="PServiceProcess" shape="rect" coords="192,168,374,192"><area href="classPHTTPServiceProcess.html" alt="PHTTPServiceProcess" shape="rect" coords="192,224,374,248"><area href="classPSecureHTTPServiceProcess.html" alt="PSecureHTTPServiceProcess" shape="rect" coords="192,280,374,304"></map><a href="classPThread-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr><tr><td colspan=2><br><h2>Construction</h2></td></tr><tr><td nowrap align=right valign=top>enum &nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z437_0">Priority</a> { <br>&nbsp;&nbsp;<a class="el" href="classPThread.html#z437_0s0">LowestPriority</a>, <a class="el" href="classPThread.html#z437_0s1">LowPriority</a>, <a class="el" href="classPThread.html#z437_0s2">NormalPriority</a>, <a class="el" href="classPThread.html#z437_0s3">HighPriority</a>, <br>&nbsp;&nbsp;<a class="el" href="classPThread.html#z437_0s4">HighestPriority</a>, <a class="el" href="classPThread.html#z437_0s5">NumPriorities</a><br> }</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Codes for thread priorities.</em> <a href="#z437_0">More...</a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>enum &nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z437_1">AutoDeleteFlag</a> { <a class="el" href="classPThread.html#z437_1s6">AutoDeleteThread</a>, <a class="el" href="classPThread.html#z437_1s7">NoAutoDeleteThread</a> }</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Codes for thread autodelete flag.</em> <a href="#z437_1">More...</a><em></em></font><br><br></td></tr><tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z437_2">PThread</a> (PINDEX, <a class="el" href="classPThread.html#z437_1">AutoDeleteFlag</a> deletion=AutoDeleteThread, <a class="el" href="classPThread.html#z437_0">Priority</a> priorityLevel=NormalPriority, const <a class="el" href="classPString.html">PString</a> &amp;threadName=PString::Empty())</td></tr><tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z437_3">~PThread</a> ()</td></tr><tr><td colspan=2><br><h2>Control functions</h2></td></tr><tr><td nowrap align=right valign=top>virtual void&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z441_0">Restart</a> ()</td></tr><tr><td nowrap align=right valign=top>virtual void&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z441_1">Terminate</a> ()</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z441_2">IsTerminated</a> () const</td></tr><tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z441_3">WaitForTermination</a> () const</td></tr><tr><td nowrap align=right valign=top>BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z441_4">WaitForTermination</a> (const <a class="el" href="classPTimeInterval.html">PTimeInterval</a> &amp;maxWait) const</td></tr><tr><td nowrap align=right valign=top>virtual void&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z441_5">Suspend</a> (BOOL susp=TRUE)</td></tr><tr><td nowrap align=right valign=top>virtual void&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z441_6">Resume</a> ()</td></tr><tr><td nowrap align=right valign=top>virtual BOOL&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z441_7">IsSuspended</a> () const</td></tr><tr><td nowrap align=right valign=top>virtual void&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z441_8">SetPriority</a> (<a class="el" href="classPThread.html#z437_0">Priority</a> priorityLevel)</td></tr><tr><td nowrap align=right valign=top>virtual <a class="el" href="classPThread.html#z437_0">Priority</a>&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z441_9">GetPriority</a> () const</td></tr><tr><td nowrap align=right valign=top>virtual void&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z441_10">SetAutoDelete</a> (<a class="el" href="classPThread.html#z437_1">AutoDeleteFlag</a> deletion=AutoDeleteThread)</td></tr><tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z441_11">SetNoAutoDelete</a> ()</td></tr><tr><td nowrap align=right valign=top>virtual <a class="el" href="classPString.html">PString</a>&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z441_12">GetThreadName</a> () const</td></tr><tr><td nowrap align=right valign=top>virtual void&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z441_13">SetThreadName</a> (const <a class="el" href="classPString.html">PString</a> &amp;name)</td></tr><tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z441_14">Sleep</a> (const <a class="el" href="classPTimeInterval.html">PTimeInterval</a> &amp;delay)</td></tr><tr><td>&nbsp;</td><td><font size=-1><em>Suspend the current thread for the specified amount of time.</em> <a href="#z441_14"></a><em></em></font><br><br></td></tr><tr><td colspan=2><br><h2>Miscellaneous</h2></td></tr><tr><td nowrap align=right valign=top>virtual <a class="el" href="thread_8h.html#a1">PThreadIdentifier</a>&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z443_0">GetThreadId</a> () const</td></tr><tr><td nowrap align=right valign=top>virtual void&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z443_1">Main</a> ()=0</td></tr><tr><td nowrap align=right valign=top><a class="el" href="thread_8h.html#a1">PThreadIdentifier</a>&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z443_2">GetCurrentThreadId</a> ()</td></tr><tr><td nowrap align=right valign=top>PThread *&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z443_3">Current</a> ()</td></tr><tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z443_4">Yield</a> ()</td></tr><tr><td nowrap align=right valign=top>PThread *&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z443_5">Create</a> (const <a class="el" href="classPNotifier.html">PNotifier</a> &amp;notifier, INT parameter=0, <a class="el" href="classPThread.html#z437_1">AutoDeleteFlag</a> deletion=AutoDeleteThread, <a class="el" href="classPThread.html#z437_0">Priority</a> priorityLevel=NormalPriority, const <a class="el" href="classPString.html">PString</a> &amp;threadName=PString::Empty(), PINDEX stackSize=10000)</td></tr><tr><td colspan=2><br><h2>Public Types</h2></td></tr><tr><td colspan=2><br><h2>Public Methods</h2></td></tr><tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#a0">PXBlockOnChildTerminate</a> (int pid, const <a class="el" href="classPTimeInterval.html">PTimeInterval</a> &amp;timeout)</td></tr><tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#a1">PXBlockOnIO</a> (int handle, int type, const <a class="el" href="classPTimeInterval.html">PTimeInterval</a> &amp;timeout)</td></tr><tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#a2">PXAbortBlock</a> () const</td></tr><tr><td colspan="2"><div class="groupHeader">Overrides from PObject</div></td></tr><tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#z439_0">PrintOn</a> (ostream &amp;strm) const</td></tr><tr><td colspan=2><br><h2>Protected Methods</h2></td></tr><tr><td nowrap align=right valign=top>void&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#b0">InitialiseProcessThread</a> ()</td></tr><tr><td colspan=2><br><h2>Friends</h2></td></tr><tr><td nowrap align=right valign=top>class&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#l0">PProcess</a></td></tr><tr><td nowrap align=right valign=top>class&nbsp;</td><td valign=bottom><a class="el" href="classPThread.html#l1">PTrace::Block</a></td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2>This class defines a thread of execution in the system. A {\it thread} is an independent flow of processor instructions. This differs from a {\it process} which also embodies a program address space and resource allocation. So threads can share memory and resources as they run in the context of a given process. A process always contains at least one thread. This is reflected in this library by the <a class="el" href="classPThread.html#l0">PProcess</a># class being descended from the PThread class.<p>The implementation of a thread is platform dependent, but it is assumed that the platform has some support for native threads. Previous versions of PWLib has some support for co-operative threads, but this has been removed <p><hr><h2>Member Enumeration Documentation</h2><a name="z437_1" doxytag="PThread::AutoDeleteFlag"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> enum PThread::AutoDeleteFlag      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Codes for thread autodelete flag.<p><dl compact><dt><b>Enumeration values: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em><a name="z437_1s6" doxytag="AutoDeleteThread"></a><em>AutoDeleteThread</em></em>&nbsp;</td><td>Automatically delete thread object on termination.</td></tr><tr><td valign=top><em><a name="z437_1s7" doxytag="NoAutoDeleteThread"></a><em>NoAutoDeleteThread</em></em>&nbsp;</td><td>Don't delete thread as it may not be on heap.</td></tr></table></dl>    </td>  </tr></table><a name="z437_0" doxytag="PThread::Priority"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> enum PThread::Priority      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Codes for thread priorities.<p><dl compact><dt><b>Enumeration values: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em><a name="z437_0s0" doxytag="LowestPriority"></a><em>LowestPriority</em></em>&nbsp;</td><td>Will only run if all other threads are blocked.</td></tr><tr><td valign=top><em><a name="z437_0s1" doxytag="LowPriority"></a><em>LowPriority</em></em>&nbsp;</td><td>Runs approximately half as often as normal.</td></tr><tr><td valign=top><em><a name="z437_0s2" doxytag="NormalPriority"></a><em>NormalPriority</em></em>&nbsp;</td><td>Normal priority for a thread.</td></tr><tr><td valign=top><em><a name="z437_0s3" doxytag="HighPriority"></a><em>HighPriority</em></em>&nbsp;</td><td>Runs approximately twice as often as normal.</td></tr><tr><td valign=top><em><a name="z437_0s4" doxytag="HighestPriority"></a><em>HighestPriority</em></em>&nbsp;</td><td>Is only thread that will run, unless blocked.</td></tr><tr><td valign=top><em><a name="z437_0s5" doxytag="NumPriorities"></a><em>NumPriorities</em></em>&nbsp;</td><td></td></tr></table></dl>    </td>  </tr></table><hr><h2>Constructor &amp; Destructor Documentation</h2><a name="z437_2" doxytag="PThread::PThread"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> PThread::PThread </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">PINDEX&nbsp;</td>          <td class="mdname" nowrap>&nbsp;, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap><a class="el" href="classPThread.html#z437_1">AutoDeleteFlag</a>&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>deletion</em> = AutoDeleteThread, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap><a class="el" href="classPThread.html#z437_0">Priority</a>&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>priorityLevel</em> = NormalPriority, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>const <a class="el" href="classPString.html">PString</a> &amp;&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>threadName</em> = PString::Empty()</td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Create a new thread instance. Unless the startSuspended# parameter is TRUE, the threads <a class="el" href="classPThread.html#z443_1">Main()</a># function is called to execute the code for the thread.<p>Note that the exact timing of the execution of code in threads can never be predicted. Thus you you can get a race condition on intialising a descendent class. To avoid this problem a thread is always started suspended. You must call the <a class="el" href="classPThread.html#z441_6">Resume()</a> function after your descendent class construction is complete.<p>If synchronisation is required between threads then the use of semaphores is essential.<p>If the deletion# is set to <a class="el" href="classPThread.html#z437_1s6">AutoDeleteThread</a># then the PThread is assumed to be allocated with the new operator and may be freed using the delete operator as soon as the thread is terminated or executes to completion (usually the latter).<p>The stack size argument retained only for source code compatibility for previous implementations. It is not used in the current code and may be removed in subsequent versions. <dl compact><dt><b>Parameters: </b></dt><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>deletion</em>&nbsp;</td><td>Not used - previously stack size </td></tr><tr><td valign=top><em>priorityLevel</em>&nbsp;</td><td>Automatically delete PThread instance on termination of thread. </td></tr><tr><td valign=top><em>threadName</em>&nbsp;</td><td>Initial priority of thread. The name of the thread (for Debug/Trace) </td></tr></table></dl>    </td>  </tr></table><a name="z437_3" doxytag="PThread::~PThread"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> PThread::~PThread </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="mdname1" valign="top" nowrap>&nbsp;          </td>          <td class="md" valign="top">)&nbsp;</td>          <td class="md" nowrap></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Destroy the thread, this simply calls the <a class="el" href="classPThread.html#z441_1">Terminate()</a># function with all its restrictions and penalties. See that function for more information.<p>Note that the correct way for a thread to terminate is to return from the <a class="el" href="classPThread.html#z443_1">Main()</a># function.     </td>  </tr></table><hr><h2>Member Function Documentation</h2><a name="z443_5" doxytag="PThread::Create"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0">  <tr>    <td class="md">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top"> PThread* PThread::Create </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">const <a class="el" href="classPNotifier.html">PNotifier</a> &amp;&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>notifier</em>, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>INT&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>parameter</em> = 0, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap><a class="el" href="classPThread.html#z437_1">AutoDeleteFlag</a>&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>deletion</em> = AutoDeleteThread, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap><a class="el" href="classPThread.html#z437_0">Priority</a>&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>priorityLevel</em> = NormalPriority, </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>const <a class="el" href="classPString.html">PString</a> &amp;&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>threadName</em> = PString::Empty(), </td>        </tr>        <tr>          <td></td>          <td></td>          <td class="md" nowrap>PINDEX&nbsp;</td>          <td class="mdname" nowrap>&nbsp; <em>stackSize</em> = 10000</td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"><code> [static]</code></td>        </tr>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -