📄 classthread.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Copley Motion Library: Thread Class Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.4 --><div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a></div><h1>Thread Class Reference</h1><!-- doxytag: class="Thread" --><p>Inheritance diagram for Thread:<p><center><img src="classThread.png" usemap="#Thread_map" border="0" alt=""></center><map name="Thread_map"><area href="classCanOpen.html" alt="CanOpen" shape="rect" coords="0,56,82,80"><area href="classLinkage.html" alt="Linkage" shape="rect" coords="92,56,174,80"><area href="classNode.html" alt="Node" shape="rect" coords="184,56,266,80"><area href="classCopleyNode.html" alt="CopleyNode" shape="rect" coords="138,112,220,136"><area href="classIOModule.html" alt="IOModule" shape="rect" coords="230,112,312,136"><area href="classAmp.html" alt="Amp" shape="rect" coords="138,168,220,192"></map><a href="classThread-members.html">List of all members.</a><hr><a name="_details"></a><h2>Detailed Description</h2>Virtual class which provides multi-tasking. <p>To add a new thread to a program, create a new class that is derived from Thread. The new thread of execution will start when the <a class="el" href="classThread.html#a3">start()</a> member function is called. This new thread of execution will start with the <a class="el" href="classThread.html#a5">run()</a> member function and will run concurrently with the rest of the system. When (if) the run method returns, the new thread will be terminated.<p><p>Definition at line <a class="el" href="CML__Threads_8h-source.html#l00070">70</a> of file <a class="el" href="CML__Threads_8h-source.html">CML_Threads.h</a>.<table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr><tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classThread.html#a0">Thread</a> (void)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Create a new thread. <a href="#a0"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a1"></a><!-- doxytag: member="Thread::~Thread" ref="a1" args="()" -->virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classThread.html#a1">~Thread</a> ()</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Clean up any allocated resources. <br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="classError.html">Error</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classThread.html#a2">setPriority</a> (int pri)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Set the thread priority. <a href="#a2"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="classError.html">Error</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classThread.html#a3">start</a> (void)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Make this thread eligible to run. <a href="#a3"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="classError.html">Error</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classThread.html#a4">stop</a> (<a class="el" href="CML__Utils_8h.html#a9">int32</a> timeout=1000)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Stop this thread. <a href="#a4"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classThread.html#a5">run</a> (void)=0</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">When a new thread is started, this function will be called. <a href="#a5"></a><br></td></tr><tr><td colspan="2"><br><h2>Static Public Member Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">static const <a class="el" href="classError.html">Error</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classThread.html#e0">sleep</a> (<a class="el" href="CML__Utils_8h.html#a9">int32</a> timeout)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Cause the calling thread to sleep for a specified number of milliseconds. <a href="#e0"></a><br></td></tr></table><hr><h2>Constructor & Destructor Documentation</h2><a class="anchor" name="a0"></a><!-- doxytag: member="Thread::Thread" ref="a0" args="(void)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"><a class="el" href="classThread.html">Thread</a> </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Create a new thread. <p>The new thread will not start executing until the start member function of this class is called. The default thread priority will be set to 5. </td> </tr></table><hr><h2>Member Function Documentation</h2><a class="anchor" name="a5"></a><!-- doxytag: member="Thread::run" ref="a5" args="(void)=0" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">virtual void run </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [pure virtual]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>When a new thread is started, this function will be called. <p>All of the thread specific code should be contained in this function. If the <a class="el" href="classThread.html#a5">run()</a> method ever returns, the thread will be destroyed. <p>Implemented in <a class="el" href="classNode.html#a40">Node</a>. </td> </tr></table><a class="anchor" name="a2"></a><!-- doxytag: member="Thread::setPriority" ref="a2" args="(int pri)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">const <a class="el" href="classError.html">Error</a>* setPriority </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">int </td> <td class="mdname1" valign="top" nowrap> <em>pri</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Set the thread priority. <p>This function should be called before the thread is started if the default priority (5) is not acceptable. <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>pri</em> </td><td>The priority for this thread to run at. The range is 0 to 9 where 0 is a very low priority task, and 9 is a critically high priority. </td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd>An error object is returned indicating the success of the call. </dd></dl> </td> </tr></table><a class="anchor" name="e0"></a><!-- doxytag: member="Thread::sleep" ref="e0" args="(int32 timeout)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">static const <a class="el" href="classError.html">Error</a>* sleep </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="CML__Utils_8h.html#a9">int32</a> </td> <td class="mdname1" valign="top" nowrap> <em>timeout</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [static]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Cause the calling thread to sleep for a specified number of milliseconds. <p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>The time to sleep, in milliseconds. </td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd>An error object is returned indicating the success of the call. </dd></dl> </td> </tr></table><a class="anchor" name="a3"></a><!-- doxytag: member="Thread::start" ref="a3" args="(void)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">const <a class="el" href="classError.html">Error</a>* start </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Make this thread eligible to run. <p>The new thread will be created if possible and identified to the operating system as eligible to run. When the thread actually starts, the <a class="el" href="classThread.html#a5">run()</a> method will be called. Note that depending on the priority of the thread and of the calling task, the <a class="el" href="classThread.html#a5">run()</a> function may or may not be called before <a class="el" href="classThread.html#a3">start()</a> returns. <dl compact><dt><b>Returns:</b></dt><dd>An error object is returned indicating the success of the call. </dd></dl> </td> </tr></table><a class="anchor" name="a4"></a><!-- doxytag: member="Thread::stop" ref="a4" args="(int32 timeout=1000)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">const <a class="el" href="classError.html">Error</a>* stop </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="CML__Utils_8h.html#a9">int32</a> </td> <td class="mdname1" valign="top" nowrap> <em>timeout</em> = <code>1000</code> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Stop this thread. <p>The thread will have exited by the time this function returns. If the calling thread is the thread being stopped, then this function will not return. <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>The amount of time to wait (milliseconds) for the thread to stop before returning an error. </td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd>An error object is returned indicating the success of the call. </dd></dl> </td> </tr></table><hr>The documentation for this class was generated from the following file:<ul><li><a class="el" href="CML__Threads_8h-source.html">CML_Threads.h</a></ul><hr><address style="align: right;"><small>Copley Motion Library, Copyright (c) 2002-2003<a href="http://www.copleycontrols.com"><img src="CCC_logo.gif" alt="Copley Controls Corp." align="middle" border=0 ></a></small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -